-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Whitelist attribute xml:space not recognised #64
Comments
Problem is: https://github.com/darylldoyle/svg-sanitizer/blob/master/src/Sanitizer.php#L369 Change:
to
it solves the problem, I'm unsure about the side effects... |
Three problems:
So please use |
Just fixed this locally, and then realized there may be an opened issue already... Opened a pull-request, hoping this will be fixed, because currently, there is no way to determine whether the file was sanitized or not. |
Note however that "xml:" is not a really namespace in XML, so it doe snot have to be declared (it is implicitly defined and reserved for the XML standard itself) and "xml:whitespace" is an implicit property that is defined and valid in all XML files, independantly of their processing schema: it must be processed directly at parser level without any need of further processing and it is not subject to any interpretation. You can treat it as a "pseudo" namespace, though, given that no valid XML file can redefine it with a valid XML namespace declaration, so it can safely be bound internally when using any XML parser, including for parsing any version of SVG or any reduced profile (such as TinyVG whose purpose is only to preserve a standard "minimal" rendering comptible with all devices, while dropping most other metadata and semantic informations, e.g. for project management, sources, licencing conditions, etc.). [ It is just the same for implicitly predefined entities "amp", "lt", and "gt", and the generic syntax of numerical character references that are handled at parser level; this difference just contrasts with SGML and legacy HTML parsers before HTML5, that required such declaration, in a DTD schema, but not with XHTML which is prebound to XML, independantly of the schemas used for HTML4, HTML5 and their evolutions and independantly of the new stricter HTML5 parser that adds further extensions and restrictions not defined in XML, such as new predefined entities and attributes and the deprecation of must namespaces in HTML5 which is then not extensible in its syntax except by converting HTML5 to XHTML via the XML syntax, where you then need to add explicit declarations of additional HTML5 entities in an explicit schema; but thanks, HTML5 provides the stadnard URI for these standardized schema extension so that HTML5 parser can produce a unique predicatible HTML5 while uniquely preserving the DOM with a bijection between the two syntaxes, considered completely equivalent even it the standard schema is then evolutive and must be backward compatible with previous specifications of HTML5; this also applies to the integration of a part of SVG inside HTML5, but with a restriction: it can only use XML 1.1 and not XML 1.0, as HTML5 does not allow specifying any embedded DTD but only an implicit external schema. ] |
We have exported a SVG with Adobe and the sanitizer does not like that. It give the following errors:
There are sanitization issues with this SVG file:
Suspicious attribute 'space' in line 4
Suspicious attribute 'enable-background' in line 4
Generator is: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)
Issue #63 is for the enable-background.
But the space attribute is something weird.
Relevant code of the SVG:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="Layer_1" version="1.1" x="0px" y="0px" width="600px" height="600px" viewBox="0 0 600 600" xml:space="preserve">
If you sanitize this the getXmlIssues() function wil return the error above:
Suspicious attribute 'space' in line 4
Somehow the code strips xml:
Did not found the problem/solution for this.
The text was updated successfully, but these errors were encountered: