1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2024-12-23 08:30:38 +01:00

Improved charset detection in HTML source code

This commit is contained in:
nobody 2020-05-25 06:19:17 +02:00
parent c1adace8c3
commit 91527a186c
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
2 changed files with 2 additions and 5 deletions

View File

@ -64,10 +64,7 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
if (!charset) { if (!charset) {
//content-type has no charset declared //content-type has no charset declared
let htmlHead = asciiDecoder.decode(evt.data, {stream: false}); let htmlHead = asciiDecoder.decode(evt.data, {stream: false});
let charsetMatch = htmlHead.match(/<meta\s+charset=["']?([^>"'\/]+)["'>\/]/i); let charsetMatch = htmlHead.match(/<meta.*charset=["']?([^>"'\/]+)["'].*[>\/]/i);
if (!charsetMatch) {
charsetMatch = htmlHead.match(/<meta\s+http-equiv=["']?content-type["']?\s+content=["']?text\/html;\s*charset=([^>"'\/]+)["'>\/]/i);
}
charset = charsetMatch ? charsetMatch[1] : "UTF-8"; charset = charsetMatch ? charsetMatch[1] : "UTF-8";
} }
decoder = new TextDecoder(charset); decoder = new TextDecoder(charset);

View File

@ -23,7 +23,7 @@
New in LocalCDN: New in LocalCDN:
</div> </div>
<ul> <ul>
<li></li> <li>Improved charset detection in HTML source code</li>
</ul> </ul>
<div class="topic-label"> <div class="topic-label">
Please update your uBlock/uMatrix rules Please update your uBlock/uMatrix rules