Skip to content

Packaging includes control characters in HTML #986

@cmahnke

Description

@cmahnke

I try to wrap my head around serving packages using Vite.
This currently wont't work, since the generated HTML includes control characters and parse5, the HTML parser used by Vite doesn't like those.

Trying to fix this using brute force like this won't work either, since the internal unziper doesn't seem to understand the escaped characters.

let htmlStr = new TextDecoder().decode(html);
/*
// These are parts of the Zip header
htmlStr = htmlStr.replace(/PK\x03\x04/g, "PK");
htmlStr = htmlStr.replace(/PK\x01\x02/g, "PK");
htmlStr = htmlStr.replace(/PK\x06\x06/g, "PK");
htmlStr = htmlStr.replace(/PK\x06\x07/g, "PK");
htmlStr = htmlStr.replace(/PK\x07/g, "PK");
htmlStr = htmlStr.replace(/PK\x05\x06/g, "PK");
// This is the ESC char for ansi codes
htmlStr = htmlStr.replace(/\x1B/g, "");
htmlStr = htmlStr.replace(/\x1F/g, "");
// This is a DOS line ending
htmlStr = htmlStr.replace(/\x1A/g, "");

Is there a known way to work around this?
Can control characters in HTML can be avoided in the future in general?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions