Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { readyState } = this;
if (readyState === XMLHttpRequest.LOADING || readyState === XMLHttpRequest.DONE) {
throw new DOMException("The object is in an invalid state.", "InvalidStateError");
}
this[xhrSymbols.flag].overrideMIMEType = "application/octet-stream";
// Waiting for better spec: https://github.com/whatwg/xhr/issues/157
const parsed = MIMEType.parse(mime);
if (parsed) {
this[xhrSymbols.flag].overrideMIMEType = parsed.essence;
const charset = parsed.parameters.get("charset");
if (charset) {
this[xhrSymbols.flag].overrideCharset = whatwgEncoding.labelToName(charset);
}
}
}
return whatwgEncoding.labelToName(string.substring(position + 1, nextIndex));
}
// It is an unmatched quotation mark
return null;
}
if (string.length === position + 1) {
return null;
}
let end = string.substring(position + 1).search(/\x09|\x0A|\x0C|\x0D|\x20|;/);
if (end === -1) {
end = string.length;
}
return whatwgEncoding.labelToName(string.substring(position, end));
}
function fetchStylesheetInternal(elementImpl, urlString, parsedURL) {
let defaultEncoding = elementImpl._ownerDocument._encoding;
if (elementImpl.localName === "link" && elementImpl.hasAttribute("charset")) {
defaultEncoding = whatwgEncoding.labelToName(elementImpl.getAttribute("charset"));
}
resourceLoader.load(elementImpl, urlString, { defaultEncoding }, data => {
// TODO: MIME type checking?
if (elementImpl.sheet) {
exports.removeStylesheet(elementImpl.sheet, elementImpl);
}
exports.createStylesheet(data, elementImpl, parsedURL);
});
}
const { readyState } = this;
if (readyState === XMLHttpRequest.LOADING || readyState === XMLHttpRequest.DONE) {
throw new DOMException("The object is in an invalid state.", "InvalidStateError");
}
this[xhrSymbols.flag].overrideMIMEType = "application/octet-stream";
// Waiting for better spec: https://github.com/whatwg/xhr/issues/157
const parsed = MIMEType.parse(mime);
if (parsed) {
this[xhrSymbols.flag].overrideMIMEType = parsed.essence;
const charset = parsed.parameters.get("charset");
if (charset) {
this[xhrSymbols.flag].overrideCharset = whatwgEncoding.labelToName(charset);
}
}
}
function fetchStylesheetInternal(elementImpl, urlString, parsedURL) {
let defaultEncoding = elementImpl._ownerDocument._encoding;
if (elementImpl.localName === "link" && elementImpl.hasAttribute("charset")) {
defaultEncoding = whatwgEncoding.labelToName(elementImpl.getAttribute("charset"));
}
resourceLoader.load(elementImpl, urlString, { defaultEncoding }, data => {
// TODO: MIME type checking?
if (elementImpl.sheet) {
exports.removeStylesheet(elementImpl.sheet, elementImpl);
}
exports.createStylesheet(data, elementImpl, parsedURL);
});
}
function fetchStylesheetInternal(elementImpl, urlString, parsedURL) {
const document = elementImpl._ownerDocument;
let defaultEncoding = document._encoding;
const resourceLoader = document._resourceLoader;
if (elementImpl.localName === "link" && elementImpl.hasAttributeNS(null, "charset")) {
defaultEncoding = whatwgEncoding.labelToName(elementImpl.getAttributeNS(null, "charset"));
}
function onStylesheetLoad(data) {
const css = whatwgEncoding.decode(data, defaultEncoding);
// TODO: MIME type checking?
if (elementImpl.sheet) {
exports.removeStylesheet(elementImpl.sheet, elementImpl);
}
exports.createStylesheet(css, elementImpl, parsedURL);
}
resourceLoader.fetch(urlString, {
element: elementImpl,
onLoad: onStylesheetLoad
});
readAsText(file, encoding) {
this._readFile(file, "text", whatwgEncoding.labelToName(encoding) || "UTF-8");
}
function finalCharset(xhr) {
const flag = xhr[xhrSymbols.flag];
if (flag.overrideCharset) {
return flag.overrideCharset;
}
const parsedContentType = MIMEType.parse(getResponseHeader(xhr, "content-type"));
if (parsedContentType) {
return whatwgEncoding.labelToName(parsedContentType.parameters.get("charset"));
}
return null;
}
function finalCharset(xhr) {
const flag = xhr[xhrSymbols.flag];
if (flag.overrideCharset) {
return flag.overrideCharset;
}
const parsedContentType = MIMEType.parse(getResponseHeader(xhr, "content-type"));
if (parsedContentType) {
return whatwgEncoding.labelToName(parsedContentType.parameters.get("charset"));
}
return null;
}
function finalCharset(xhr) {
const flag = xhr[xhrSymbols.flag];
if (flag.overrideCharset) {
return flag.overrideCharset;
}
const parsedContentType = MIMEType.parse(getResponseHeader(xhr, "content-type"));
if (parsedContentType) {
return whatwgEncoding.labelToName(parsedContentType.parameters.get("charset"));
}
return null;
}