Skip to content

The SVG 'style' attribute parsing is not CSS standard compliant #145

@dhendriks

Description

@dhendriks

The AttributeNode.preprocessAttributes method has the following code:

    private static void preprocessAttributes(@NotNull Map<String, String> attributes,
            @NotNull Map<String, String> styleAttributes) {
        String styleStr = attributes.get("style");
        if (styleStr != null && !isBlank(styleStr)) {
            String[] styles = styleStr.split(";");
            for (String style : styles) {
                if (isBlank(style)) continue;
                String[] styleDef = style.split(":", 2);
                styleAttributes.put(styleDef[0].trim().toLowerCase(Locale.ENGLISH), styleDef[1].trim());
            }
        }
    }

It parses the style attribute by splitting on ; and then :. This is not CSS standard compliant, as it doesn't consider comments, quoted strings, etc. It should be parsed like a declaration in a style sheet, according to the standard: https://www.w3.org/TR/css-style-attr/.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions