Skip to content

SVG data:URIs with length > ~700 chars and an unescaped newline will hang the parser #50

@RoyTinker

Description

@RoyTinker

This problem is most prevalent when embedding SVG files as data:URIs. Sometimes a newline slips through without an escape. The following will hang PrettyCSS:

.svg-icon {
    background-image: url("data:image/svg+xml,\
        %3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E\
        %3Cpath d='M224%20387.814V512L32 320l192-192v126.912C447.375 \
            260.152 437.794 103.016 380.93 0 521.287 151.707 491.48 394.785 224 \
            387.814z'/%3E%\
        %3Cpath d='M224%20387.814V512L32 320l192-192v126.912C447.375 \
            260.152 437.794 103.016 380.93 0 521.287 151.707 491.48 394.785 224 \
            387.814z'/%3E%\
        %3Cpath d='M224%20387.814V512L32 320l192-192v126.912C447.375 \
            260.152 437.794 103.016 380.93 0 521.287 151.707 491.48 394.785 224 \
            387.814z'/%3E%\
        %3Cpath d='M224%20387.814V512L32 320l192-192v126.912C447.375 \
            260.152 437.794 103.016 380.93 0 521.287 151.707 491.48 394.785 224 \
            387.814z'/%3E\
        %3C/svg%3E
");
}

The unescaped newline is right before the end quote.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions