Every code SvgValidator reports, its message, and what to change so the file passes. The
message is the template with the detail filled in at %s. Codes never change once
released; message wording can, so match on code.
| Code | Message | What to do |
|---|---|---|
file-unreadable |
Cannot read file %s |
Pass the upload's tmp_name, check $_FILES['logo']['error'] first, and run the check before move_uploaded_file(). |
not-svg |
This is not an SVG file: it starts with %s |
Export the file as SVG from the design tool. Renaming a PNG or PDF does not convert it. |
not-utf8 |
SVG files must be UTF-8, this one is %s |
Save the file as UTF-8. Every design tool and code editor does this by default; older Windows Notepad wrote UTF-16 when "Unicode" was picked in Save As. |
malformed-xml |
The SVG is not well-formed XML: %s |
The detail names the line. An HTML entity such as is the usual cause in a hand-edited file: write   or the character itself. An unclosed tag means a hand edit or a truncated transfer: re-export. |
doctype-not-allowed |
The DOCTYPE declaration is not allowed because %s |
In Illustrator, uncheck "Preserve Illustrator Editing Capabilities" in SVG Options and export again. Keep the .ai file as the editable copy. |
processing-instruction |
Processing instructions like <?%s?> are not allowed |
Move the CSS from <?xml-stylesheet?> into a <style> element, or remove it. |
comment-not-allowed |
A comment starting with <!--%s is not allowed, HTML parsers close it there |
Put a space or any text after <!--. |
cdata-not-allowed |
A CDATA section containing > is not allowed inside <%s>, HTML parsers end it there |
Write the title or description as plain text, with > as >. |
root-not-svg |
The root element must be <svg>, not <%s> |
Upload the SVG file itself, not an HTML page that contains it. |
root-namespace-wrong |
The root <svg> element must declare xmlns="http://www.w3.org/2000/svg", but it has %s |
Add xmlns="http://www.w3.org/2000/svg" to the root element. Snippets copied out of a web page are missing it; design tools always write it. |
element-not-allowed |
<%s> is not allowed in uploaded SVGs |
Remove the element. Older Inkscape wrote <flowRoot> for a dragged text box: select the text, then Text → Convert to Text, or Path → Object to Path. draw.io writes <foreignObject> for formatted labels: set the labels to plain text before exporting. |
namespace-not-allowed |
Elements from the XML namespace %s are not allowed |
Remove the element. Inkscape, Illustrator, Affinity Designer, Sketch and Visio metadata is ignored and never triggers this; XHTML, MathML and anything unknown does. |
event-handler |
%s= event handler attributes are not allowed |
Remove the attribute. No design tool writes one. |
attribute-not-allowed |
The %s attribute is not allowed |
Remove the attribute. If a current design tool wrote it, open an issue with the file. |
href-not-allowed |
href must reference an element in the same file (#id), not %s |
Copy the referenced element into this file and point at it with #id. For a link (<a>), remove it from the artwork and wrap the <img> tag in the page with the link instead. |
image-href-not-allowed |
Image href must be #id or an embedded PNG, JPEG, GIF, WebP or SVG data: URL, not %s |
Export with images embedded. Illustrator: Image Location → Embed. Inkscape: "Embed images" in Save As, or select the image and use Extensions → Images → Embed Images. Affinity Designer: "Embed images" under More on the export panel. Figma always embeds. |
embedded-svg-not-allowed |
An embedded SVG image was rejected: %s |
Fix the inner SVG (the detail is its message), or embed a PNG instead. |
url-not-fragment |
url() in the %s attribute must reference an element in the same file (#id) |
Define the gradient, pattern, filter or mask in this file and reference it with url(#id). |
reference-expansion-too-large |
The references in this file %s |
For a loop, the detail names it: break it. For a count, flatten the repeated art in the design tool; a real illustration never needs a hundred thousand rendered elements. |
css-not-allowed |
CSS containing %s is not allowed |
Embed the font as src: url(data:font/woff2;base64,...) in @font-face, or convert the text to outlines. Illustrator: Fonts → Convert to Outlines in SVG Options, or Type → Create Outlines. Figma: Outline Text on export. Inkscape: Path → Object to Path. A backslash in CSS rejects too: write the value without escapes. |
animation-target-not-allowed |
Animating the %s attribute is not allowed |
Animate a presentation attribute instead, or switch between two elements with visibility. |
animation-value-not-allowed |
The %s animation attribute contains a URL or scheme |
Animation values are colors, numbers, lengths and paths. Remove the URL. |
To translate a message, run template through your translation function and put detail
back with sprintf(), then encode the whole result, since the template itself holds <
and >: echo htmlspecialchars(sprintf(t($violation->template), $violation->detail));.
Violation::TEMPLATES holds every template keyed by code, so a translation system can
register them all up front.
Three things to know when reading a result:
- A small malformed file reports only
malformed-xml. libxml2 parses in chunks and discards the chunk holding the error, and in a small file that chunk is the whole file. Fix the XML and check again; the other problems are reported then. - "Cannot read file php3F.tmp" means the temporary file was gone before the check.
Either
move_uploaded_file()ran first, the upload failed, ornamewas passed instead oftmp_name. - The same problem on five elements is reported once. Errors are deduplicated by code
and detail: five
<script>elements are one error, five differenton*attributes are five. The list stops at 50 distinct problems.