Disallow 'text'-tags in SVG-images

This commit is contained in:
Pieter Vander Vennet 2022-05-07 21:41:58 +02:00
parent a091f3b7b4
commit e08a7ca2cf
10 changed files with 19918 additions and 21112 deletions

View file

@ -121,17 +121,21 @@ class LayerOverviewUtils {
continue
}
const contents = readFileSync(path, "UTF8")
if (contents.indexOf("data:image/png;") < 0) {
continue;
if (contents.indexOf("data:image/png;") >= 0) {
console.warn("The SVG at " + path + " is a fake SVG: it contains PNG data!")
errCount++;
if (path.startsWith("./assets/svg")) {
throw "A core SVG is actually a PNG. Don't do this!"
}
}
console.warn("The SVG at " + path + " is a fake SVG: it contains PNG data!")
errCount++;
if (path.startsWith("./assets/svg")) {
throw "A core SVG is actually a PNG. Don't do this!"
if(contents.indexOf("<text")>0){
console.warn("The SVG at " + path + " contains a `text`-tag. This is highly discouraged. Every machine viewing your theme has their own font libary, and the font you choose might not be present, resulting in a different font being rendered. Solution: open your .svg in inkscape (or another program), select the text and convert it to a path")
errCount++;
}
}
if (errCount > 0) {
throw `There are ${errCount} fake svgs`
throw `There are ${errCount} invalid svgs`
}
}