|
@@ -104,11 +104,14 @@ this.SingleFileBrowser = this.SingleFileBrowser || (() => {
|
|
|
if (!contentType.includes("/")) {
|
|
if (!contentType.includes("/")) {
|
|
|
contentType = null;
|
|
contentType = null;
|
|
|
}
|
|
}
|
|
|
- const charsetValue = matchContentType[1] && matchContentType[1].trim();
|
|
|
|
|
|
|
+ const charsetValue = matchContentType[1] && matchContentType[1].trim().toLowerCase();
|
|
|
if (charsetValue) {
|
|
if (charsetValue) {
|
|
|
const matchCharset = charsetValue.match(/^charset=(.*)/);
|
|
const matchCharset = charsetValue.match(/^charset=(.*)/);
|
|
|
- if (matchCharset) {
|
|
|
|
|
- charset = docHelper.removeQuotes(matchCharset[1]);
|
|
|
|
|
|
|
+ if (matchCharset && matchCharset[1]) {
|
|
|
|
|
+ charset = docHelper.removeQuotes(matchCharset[1].trim());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!charset && options.charset) {
|
|
|
|
|
+ charset = options.charset.trim();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -136,12 +139,6 @@ this.SingleFileBrowser = this.SingleFileBrowser || (() => {
|
|
|
if (resourceContent.status >= 400 || (options.validateTextContentType && contentType && !contentType.startsWith(PREFIX_CONTENT_TYPE_TEXT))) {
|
|
if (resourceContent.status >= 400 || (options.validateTextContentType && contentType && !contentType.startsWith(PREFIX_CONTENT_TYPE_TEXT))) {
|
|
|
return { data: "", resourceURL };
|
|
return { data: "", resourceURL };
|
|
|
}
|
|
}
|
|
|
- if (!charset) {
|
|
|
|
|
- const matchCharset = contentType && contentType.match(/\s*;\s*charset\s*=\s*"?([^";]*)"?(;|$)/i);
|
|
|
|
|
- if (matchCharset && matchCharset[1] || options.charset) {
|
|
|
|
|
- charset = (matchCharset && matchCharset[1].toLowerCase()) || options.charset;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
if (!charset) {
|
|
if (!charset) {
|
|
|
charset = "utf-8";
|
|
charset = "utf-8";
|
|
|
}
|
|
}
|