Incorrect insertion of the UTF8 charset in the HTML filter (#782)

This commit is contained in:
nobody 2021-11-24 07:22:11 +01:00
parent 8a068a3941
commit c91d85d53a
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
2 changed files with 16 additions and 1 deletions

View File

@ -118,7 +118,7 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
str += decoder.decode(); // end-of-stream
// set UTF-8 in document
str = str.replace(new RegExp(`charset=["']?${charset}["']?`), 'charset="utf8"');
str = manipulateDOM._searchCharset(str, charset);
// remove crossorigin and integrity attributes
str = str.replace(/<(link|script)[^>]+>/ig, (m) => {
@ -138,6 +138,17 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
}
};
manipulateDOM._searchCharset = function (str, charset) {
if (str.indexOf(`charset="${charset}"`) > 0) {
return str.replace(`charset="${charset}"`, 'charset="utf8"');
} else if (str.indexOf(`charset='${charset}'`) > 0) {
return str.replace(`charset='${charset}'`, 'charset=\'utf8\'');
} else if (str.indexOf(`charset=${charset}`) > 0) {
return str.replace(`charset=${charset}`, 'charset=utf8');
} else {
return str;
}
};
/**
* Initializations

View File

@ -60,6 +60,10 @@
<li>i18n: Vietnamese</li>
<li>ember.js v4.0.0 (<a href="https://codeberg.org/nobody/LocalCDN/issues/781">#781</a>)</li>
</ul>
<p>Fixed</p>
<ul>
<li>Incorrect insertion of the UTF8 charset in the HTML filter (<a href="https://codeberg.org/nobody/LocalCDN/issues/782">#782</a>)</li>
</ul>
</div>
<div id="generator-section">
<div class="topic-label">