-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Error overlay html encodes the ansi html formatting the error output #3575
Comments
Currently a formatting issue in the overlay, ref: webpack/webpack-dev-server#3575
I believe this is a duplicate of #3552 which is already fixed (but not released). |
@erikt9 Im not sure that I agree... the work you refer to doesn't test or solve the escaping issue. |
@raix Is it possible for you to provide a minimal reproduction repo for testing? |
For CRA:
Possible replication by adding this test to it("should show on an formatted error for initial compilation", async () => {
const compiler = webpack(config);
new ErrorPlugin("�[0m �[90m 18 |�[39m �[33mLearn�[39m �[33mReact�[39m�[0m").apply(compiler);
const devServerOptions = {
host: "0.0.0.0",
port,
};
const server = new Server(devServerOptions, compiler);
await new Promise((resolve, reject) => {
server.listen(devServerOptions.port, devServerOptions.host, (error) => {
if (error) {
reject(error);
return;
}
resolve();
});
});
const { page, browser } = await runBrowser();
await page.goto(`http://localhost:${port}/main`, {
waitUntil: "networkidle0",
});
const pageHtml = await page.evaluate(() => document.body.outerHTML);
const overlayHandle = await page.$("#webpack-dev-server-client-overlay");
const overlayFrame = await overlayHandle.contentFrame();
const overlayHtml = await overlayFrame.evaluate(
() => document.body.outerHTML
);
expect(prettier.format(pageHtml, { parser: "html" })).toMatchSnapshot(
"page html"
);
expect(prettier.format(overlayHtml, { parser: "html" })).toMatchSnapshot(
"overlay html"
);
await browser.close();
await new Promise((resolve) => {
server.close(() => {
resolve();
});
});
}); The produced snapshot: exports[`overlay should show on an formatted error for initial compilation: overlay html 1`] = `
"<body>
<div
id=\\"webpack-dev-server-client-overlay-div\\"
style=\\"
position: fixed;
box-sizing: border-box;
inset: 0px;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.85);
color: rgb(232, 232, 232);
font-family: Menlo, Consolas, monospace;
font-size: large;
padding: 2rem;
line-height: 1.2;
white-space: pre-wrap;
overflow: auto;
\\"
>
<span>Compiled with problems:</span
><button
style=\\"
background: transparent;
border: none;
font-size: 20px;
font-weight: bold;
color: white;
cursor: pointer;
float: right;
\\"
>
X</button
><br /><br />
<div>
<span style=\\"color: rgb(227, 96, 73)\\">Error:</span><br /><br /><span
style=\\"font-weight:normal;opacity:1;color:#transparent;background:#transparent;\\">
<span style=\\"color:#6D7891;\\"> 18 |</span> <span
style=\\"color:#FFD080;\\">Learn</span> <span
style=\\"color:#FFD080;\\">React</span></span><br /><br /><br />
</div>
</div>
</body>
"
`;
exports[`overlay should show on an formatted error for initial compilation: page html 1`] = `
"<body>
<script type=\\"text/javascript\\" charset=\\"utf-8\\" src=\\"/main.js\\"></script>
<iframe
id=\\"webpack-dev-server-client-overlay\\"
src=\\"about:blank\\"
style=\\"
position: fixed;
inset: 0px;
width: 100vw;
height: 100vh;
border: none;
z-index: 2147483647;
\\"
></iframe>
</body>
"
`; (Notice how the output from |
I've added a pull-request for fixing the issue and cover ansi formatting by tests #3579 |
Code
Reproduced in the CRA webpack 5 update branch using webpack error overlay in the WP5 CRA pr (replacing the CRA error overlay)
(The "wp5" branch is on the way to "main")
Expected Behavior
Actual Behavior
For Bugs; How can we reproduce the behavior?
ansiHTML returns error formattet using html as a text string but because it's handed of to document.createTextNode the browser will escape the string problem is that
errorMessage
is already escaped (as it should be to prevent XSS/script injection) so no need for the double escaping.Suggestion:
Change
To:
For Features; What is the motivation and/or use-case for the feature?
The text was updated successfully, but these errors were encountered: