Skip to content

Commit

Permalink
Add UTF-8 encoding hints
Browse files Browse the repository at this point in the history
text/plain (vs. application/json) should have charset specified:

-   https://datatracker.ietf.org/doc/html/rfc1521#section-7.1.1

Apart from that, specify @charset in "viewer.css" to ensure correct
decoding of generated 'content' declarations:

-   https://developer.mozilla.org/en-US/docs/Web/CSS/@charset

Fixes #218
  • Loading branch information
stanio committed Aug 24, 2024
1 parent a10aae5 commit 6bb1a46
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/background-firefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function detectJSON(event: chrome.webRequest.WebResponseHeadersDetails) {
if (typeof browser !== "undefined" && "filterResponseData" in browser.webRequest) {
// We need to change the content type to text/plain to prevent Firefox
// from using its built-in JSON viewer.
header.value = "text/plain";
header.value = "text/plain; charset=UTF-8";
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/viewer.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@charset "UTF-8";

body {
font-family: sans-serif;
margin: 0;
Expand Down

0 comments on commit 6bb1a46

Please sign in to comment.