[svg] WEB-69508 Disable spell checking for data urls

GitOrigin-RevId: a00437b815b6094ad6f2cdf7f6c3af2478e565a2
This commit is contained in:
Piotr Tomiak
2025-09-12 12:36:51 +00:00
committed by intellij-monorepo-bot
parent 7c617fd699
commit c7a0752149
3 changed files with 19 additions and 0 deletions
@@ -0,0 +1,9 @@
<?xml version="1.0" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<image
width="40"
clip-rule="evenodd"
id="<TYPO descr="Typo: In word 'foddd'">foddd</TYPO>"
xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTjMuMXoiIC8+CiAgICA8QzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNsbD0iI0ZGRkZGRiZnPg=="
/>
</svg>

After

Width:  |  Height:  |  Size: 461 B

@@ -41,6 +41,10 @@ public class XmlWithMistakesInspectionTest extends SpellcheckerInspectionTestCas
doTest("enumerations.svg");
}
public void testDataUrl() {
doTest("dataUrl.svg");
}
public void testLinkIntegrity() {
doTest("htmlIntegrity.html");
}
@@ -19,6 +19,7 @@ import com.intellij.spellchecker.tokenizer.TokenConsumer;
import com.intellij.spellchecker.tokenizer.Tokenizer;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.io.URLUtil;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.DomUtil;
import com.intellij.xml.util.XmlEnumeratedValueReference;
@@ -228,6 +229,11 @@ public class XmlSpellcheckingStrategy extends SuppressibleSpellcheckingStrategy
return;
}
// Do not inspect data URIs
if (URLUtil.isDataUri(ElementManipulators.getValueText(element))) {
return;
}
super.tokenize(element, consumer);
}