UNPKG

mini-program-cljs

Version:

1 lines 86.9 kB
["^ ","~:resource-id",["~:shadow.build.classpath/resource","goog/dom/safe.js"],"~:js","goog.provide(\"goog.dom.safe\");\ngoog.provide(\"goog.dom.safe.InsertAdjacentHtmlPosition\");\ngoog.require(\"goog.asserts\");\ngoog.require(\"goog.dom.asserts\");\ngoog.require(\"goog.functions\");\ngoog.require(\"goog.html.SafeHtml\");\ngoog.require(\"goog.html.SafeScript\");\ngoog.require(\"goog.html.SafeStyle\");\ngoog.require(\"goog.html.SafeUrl\");\ngoog.require(\"goog.html.TrustedResourceUrl\");\ngoog.require(\"goog.html.uncheckedconversions\");\ngoog.require(\"goog.string.Const\");\ngoog.require(\"goog.string.internal\");\n/** @enum {string} */ goog.dom.safe.InsertAdjacentHtmlPosition = {AFTERBEGIN:\"afterbegin\", AFTEREND:\"afterend\", BEFOREBEGIN:\"beforebegin\", BEFOREEND:\"beforeend\"};\n/**\n * @param {!Node} node\n * @param {!goog.dom.safe.InsertAdjacentHtmlPosition} position\n * @param {!goog.html.SafeHtml} html\n */\ngoog.dom.safe.insertAdjacentHtml = function(node, position, html) {\n node.insertAdjacentHTML(position, goog.html.SafeHtml.unwrapTrustedHTML(html));\n};\n/** @private @const @type {!Object<string,boolean>} */ goog.dom.safe.SET_INNER_HTML_DISALLOWED_TAGS_ = {\"MATH\":true, \"SCRIPT\":true, \"STYLE\":true, \"SVG\":true, \"TEMPLATE\":true};\n/**\n * @private\n * @return {boolean}\n */\ngoog.dom.safe.isInnerHtmlCleanupRecursive_ = goog.functions.cacheReturnValue(function() {\n if (goog.DEBUG && typeof document === \"undefined\") {\n return false;\n }\n var div = document.createElement(\"div\");\n var childDiv = document.createElement(\"div\");\n childDiv.appendChild(document.createElement(\"div\"));\n div.appendChild(childDiv);\n if (goog.DEBUG && !div.firstChild) {\n return false;\n }\n var innerChild = div.firstChild.firstChild;\n div.innerHTML = goog.html.SafeHtml.unwrapTrustedHTML(goog.html.SafeHtml.EMPTY);\n return !innerChild.parentElement;\n});\n/**\n * @param {?Element} elem\n * @param {!goog.html.SafeHtml} html\n */\ngoog.dom.safe.unsafeSetInnerHtmlDoNotUseOrElse = function(elem, html) {\n if (goog.dom.safe.isInnerHtmlCleanupRecursive_()) {\n while (elem.lastChild) {\n elem.removeChild(elem.lastChild);\n }\n }\n elem.innerHTML = goog.html.SafeHtml.unwrapTrustedHTML(html);\n};\n/**\n * @param {!Element} elem\n * @param {!goog.html.SafeHtml} html\n * @throws {Error}\n */\ngoog.dom.safe.setInnerHtml = function(elem, html) {\n if (goog.asserts.ENABLE_ASSERTS) {\n var tagName = elem.tagName.toUpperCase();\n if (goog.dom.safe.SET_INNER_HTML_DISALLOWED_TAGS_[tagName]) {\n throw new Error(\"goog.dom.safe.setInnerHtml cannot be used to set content of \" + elem.tagName + \".\");\n }\n }\n goog.dom.safe.unsafeSetInnerHtmlDoNotUseOrElse(elem, html);\n};\n/**\n * @param {!Element} elem\n * @param {!goog.html.SafeHtml} html\n */\ngoog.dom.safe.setOuterHtml = function(elem, html) {\n elem.outerHTML = goog.html.SafeHtml.unwrapTrustedHTML(html);\n};\n/**\n * @param {!Element} form\n * @param {(string|!goog.html.SafeUrl)} url\n */\ngoog.dom.safe.setFormElementAction = function(form, url) {\n /** @type {!goog.html.SafeUrl} */ var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n goog.dom.asserts.assertIsHTMLFormElement(form).action = goog.html.SafeUrl.unwrap(safeUrl);\n};\n/**\n * @param {!Element} button\n * @param {(string|!goog.html.SafeUrl)} url\n */\ngoog.dom.safe.setButtonFormAction = function(button, url) {\n /** @type {!goog.html.SafeUrl} */ var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n goog.dom.asserts.assertIsHTMLButtonElement(button).formAction = goog.html.SafeUrl.unwrap(safeUrl);\n};\n/**\n * @param {!Element} input\n * @param {(string|!goog.html.SafeUrl)} url\n */\ngoog.dom.safe.setInputFormAction = function(input, url) {\n /** @type {!goog.html.SafeUrl} */ var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n goog.dom.asserts.assertIsHTMLInputElement(input).formAction = goog.html.SafeUrl.unwrap(safeUrl);\n};\n/**\n * @param {!Element} elem\n * @param {!goog.html.SafeStyle} style\n */\ngoog.dom.safe.setStyle = function(elem, style) {\n elem.style.cssText = goog.html.SafeStyle.unwrap(style);\n};\n/**\n * @param {!Document} doc\n * @param {!goog.html.SafeHtml} html\n */\ngoog.dom.safe.documentWrite = function(doc, html) {\n doc.write(goog.html.SafeHtml.unwrapTrustedHTML(html));\n};\n/**\n * @param {!HTMLAnchorElement} anchor\n * @param {(string|!goog.html.SafeUrl)} url\n */\ngoog.dom.safe.setAnchorHref = function(anchor, url) {\n goog.dom.asserts.assertIsHTMLAnchorElement(anchor);\n /** @type {!goog.html.SafeUrl} */ var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n anchor.href = goog.html.SafeUrl.unwrap(safeUrl);\n};\n/**\n * @param {!HTMLImageElement} imageElement\n * @param {(string|!goog.html.SafeUrl)} url\n */\ngoog.dom.safe.setImageSrc = function(imageElement, url) {\n goog.dom.asserts.assertIsHTMLImageElement(imageElement);\n /** @type {!goog.html.SafeUrl} */ var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n var allowDataUrl = /^data:image\\//i.test(url);\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url, allowDataUrl);\n }\n imageElement.src = goog.html.SafeUrl.unwrap(safeUrl);\n};\n/**\n * @param {!HTMLAudioElement} audioElement\n * @param {(string|!goog.html.SafeUrl)} url\n */\ngoog.dom.safe.setAudioSrc = function(audioElement, url) {\n goog.dom.asserts.assertIsHTMLAudioElement(audioElement);\n /** @type {!goog.html.SafeUrl} */ var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n var allowDataUrl = /^data:audio\\//i.test(url);\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url, allowDataUrl);\n }\n audioElement.src = goog.html.SafeUrl.unwrap(safeUrl);\n};\n/**\n * @param {!HTMLVideoElement} videoElement\n * @param {(string|!goog.html.SafeUrl)} url\n */\ngoog.dom.safe.setVideoSrc = function(videoElement, url) {\n goog.dom.asserts.assertIsHTMLVideoElement(videoElement);\n /** @type {!goog.html.SafeUrl} */ var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n var allowDataUrl = /^data:video\\//i.test(url);\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url, allowDataUrl);\n }\n videoElement.src = goog.html.SafeUrl.unwrap(safeUrl);\n};\n/**\n * @param {!HTMLEmbedElement} embed\n * @param {!goog.html.TrustedResourceUrl} url\n */\ngoog.dom.safe.setEmbedSrc = function(embed, url) {\n goog.dom.asserts.assertIsHTMLEmbedElement(embed);\n embed.src = goog.html.TrustedResourceUrl.unwrapTrustedScriptURL(url);\n};\n/**\n * @param {!HTMLFrameElement} frame\n * @param {!goog.html.TrustedResourceUrl} url\n */\ngoog.dom.safe.setFrameSrc = function(frame, url) {\n goog.dom.asserts.assertIsHTMLFrameElement(frame);\n frame.src = goog.html.TrustedResourceUrl.unwrap(url);\n};\n/**\n * @param {!HTMLIFrameElement} iframe\n * @param {!goog.html.TrustedResourceUrl} url\n */\ngoog.dom.safe.setIframeSrc = function(iframe, url) {\n goog.dom.asserts.assertIsHTMLIFrameElement(iframe);\n iframe.src = goog.html.TrustedResourceUrl.unwrap(url);\n};\n/**\n * @param {!HTMLIFrameElement} iframe\n * @param {!goog.html.SafeHtml} html\n */\ngoog.dom.safe.setIframeSrcdoc = function(iframe, html) {\n goog.dom.asserts.assertIsHTMLIFrameElement(iframe);\n iframe.srcdoc = goog.html.SafeHtml.unwrapTrustedHTML(html);\n};\n/**\n * @param {!HTMLLinkElement} link\n * @param {(string|!goog.html.SafeUrl|!goog.html.TrustedResourceUrl)} url\n * @param {string} rel\n * @throws {Error}\n */\ngoog.dom.safe.setLinkHrefAndRel = function(link, url, rel) {\n goog.dom.asserts.assertIsHTMLLinkElement(link);\n link.rel = rel;\n if (goog.string.internal.caseInsensitiveContains(rel, \"stylesheet\")) {\n goog.asserts.assert(url instanceof goog.html.TrustedResourceUrl, 'URL must be TrustedResourceUrl because \"rel\" contains \"stylesheet\"');\n link.href = goog.html.TrustedResourceUrl.unwrap(url);\n } else {\n if (url instanceof goog.html.TrustedResourceUrl) {\n link.href = goog.html.TrustedResourceUrl.unwrap(url);\n } else {\n if (url instanceof goog.html.SafeUrl) {\n link.href = goog.html.SafeUrl.unwrap(url);\n } else {\n link.href = goog.html.SafeUrl.unwrap(goog.html.SafeUrl.sanitizeAssertUnchanged(url));\n }\n }\n }\n};\n/**\n * @param {!HTMLObjectElement} object\n * @param {!goog.html.TrustedResourceUrl} url\n */\ngoog.dom.safe.setObjectData = function(object, url) {\n goog.dom.asserts.assertIsHTMLObjectElement(object);\n object.data = goog.html.TrustedResourceUrl.unwrapTrustedScriptURL(url);\n};\n/**\n * @param {!HTMLScriptElement} script\n * @param {!goog.html.TrustedResourceUrl} url\n */\ngoog.dom.safe.setScriptSrc = function(script, url) {\n goog.dom.asserts.assertIsHTMLScriptElement(script);\n script.src = goog.html.TrustedResourceUrl.unwrapTrustedScriptURL(url);\n var nonce = goog.getScriptNonce();\n if (nonce) {\n script.setAttribute(\"nonce\", nonce);\n }\n};\n/**\n * @param {!HTMLScriptElement} script\n * @param {!goog.html.SafeScript} content\n */\ngoog.dom.safe.setScriptContent = function(script, content) {\n goog.dom.asserts.assertIsHTMLScriptElement(script);\n script.text = goog.html.SafeScript.unwrapTrustedScript(content);\n var nonce = goog.getScriptNonce();\n if (nonce) {\n script.setAttribute(\"nonce\", nonce);\n }\n};\n/**\n * @param {!Location} loc\n * @param {(string|!goog.html.SafeUrl)} url\n */\ngoog.dom.safe.setLocationHref = function(loc, url) {\n goog.dom.asserts.assertIsLocation(loc);\n /** @type {!goog.html.SafeUrl} */ var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n loc.href = goog.html.SafeUrl.unwrap(safeUrl);\n};\n/**\n * @param {!Location} loc\n * @param {(string|!goog.html.SafeUrl)} url\n */\ngoog.dom.safe.assignLocation = function(loc, url) {\n goog.dom.asserts.assertIsLocation(loc);\n /** @type {!goog.html.SafeUrl} */ var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n loc.assign(goog.html.SafeUrl.unwrap(safeUrl));\n};\n/**\n * @param {!Location} loc\n * @param {(string|!goog.html.SafeUrl)} url\n */\ngoog.dom.safe.replaceLocation = function(loc, url) {\n goog.dom.asserts.assertIsLocation(loc);\n /** @type {!goog.html.SafeUrl} */ var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n loc.replace(goog.html.SafeUrl.unwrap(safeUrl));\n};\n/**\n * @param {(string|!goog.html.SafeUrl)} url\n * @param {Window=} opt_openerWin\n * @param {!goog.string.Const=} opt_name\n * @param {string=} opt_specs\n * @param {boolean=} opt_replace\n * @return {Window}\n */\ngoog.dom.safe.openInWindow = function(url, opt_openerWin, opt_name, opt_specs, opt_replace) {\n /** @type {!goog.html.SafeUrl} */ var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n var win = opt_openerWin || goog.global;\n return win.open(goog.html.SafeUrl.unwrap(safeUrl), opt_name ? goog.string.Const.unwrap(opt_name) : \"\", opt_specs, opt_replace);\n};\n/**\n * @param {!DOMParser} parser\n * @param {!goog.html.SafeHtml} html\n * @return {?Document}\n */\ngoog.dom.safe.parseFromStringHtml = function(parser, html) {\n return goog.dom.safe.parseFromString(parser, html, \"text/html\");\n};\n/**\n * @param {!DOMParser} parser\n * @param {!goog.html.SafeHtml} content\n * @param {string} type\n * @return {?Document}\n */\ngoog.dom.safe.parseFromString = function(parser, content, type) {\n return parser.parseFromString(goog.html.SafeHtml.unwrapTrustedHTML(content), type);\n};\n/**\n * @param {!Blob} blob\n * @return {!HTMLImageElement}\n * @throws {!Error}\n */\ngoog.dom.safe.createImageFromBlob = function(blob) {\n if (!/^image\\/.*/g.test(blob.type)) {\n throw new Error(\"goog.dom.safe.createImageFromBlob only accepts MIME type image/.*.\");\n }\n var objectUrl = goog.global.URL.createObjectURL(blob);\n var image = new goog.global.Image;\n image.onload = function() {\n goog.global.URL.revokeObjectURL(objectUrl);\n };\n goog.dom.safe.setImageSrc(image, goog.html.uncheckedconversions.safeUrlFromStringKnownToSatisfyTypeContract(goog.string.Const.from(\"Image blob URL.\"), objectUrl));\n return image;\n};\n","~:source","// Copyright 2013 The Closure Library Authors. All Rights Reserved.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS-IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * @fileoverview Type-safe wrappers for unsafe DOM APIs.\n *\n * This file provides type-safe wrappers for DOM APIs that can result in\n * cross-site scripting (XSS) vulnerabilities, if the API is supplied with\n * untrusted (attacker-controlled) input. Instead of plain strings, the type\n * safe wrappers consume values of types from the goog.html package whose\n * contract promises that values are safe to use in the corresponding context.\n *\n * Hence, a program that exclusively uses the wrappers in this file (i.e., whose\n * only reference to security-sensitive raw DOM APIs are in this file) is\n * guaranteed to be free of XSS due to incorrect use of such DOM APIs (modulo\n * correctness of code that produces values of the respective goog.html types,\n * and absent code that violates type safety).\n *\n * For example, assigning to an element's .innerHTML property a string that is\n * derived (even partially) from untrusted input typically results in an XSS\n * vulnerability. The type-safe wrapper goog.dom.safe.setInnerHtml consumes a\n * value of type goog.html.SafeHtml, whose contract states that using its values\n * in a HTML context will not result in XSS. Hence a program that is free of\n * direct assignments to any element's innerHTML property (with the exception of\n * the assignment to .innerHTML in this file) is guaranteed to be free of XSS\n * due to assignment of untrusted strings to the innerHTML property.\n */\n\ngoog.provide('goog.dom.safe');\ngoog.provide('goog.dom.safe.InsertAdjacentHtmlPosition');\n\ngoog.require('goog.asserts');\ngoog.require('goog.dom.asserts');\ngoog.require('goog.functions');\ngoog.require('goog.html.SafeHtml');\ngoog.require('goog.html.SafeScript');\ngoog.require('goog.html.SafeStyle');\ngoog.require('goog.html.SafeUrl');\ngoog.require('goog.html.TrustedResourceUrl');\ngoog.require('goog.html.uncheckedconversions');\ngoog.require('goog.string.Const');\ngoog.require('goog.string.internal');\n\n\n/** @enum {string} */\ngoog.dom.safe.InsertAdjacentHtmlPosition = {\n AFTERBEGIN: 'afterbegin',\n AFTEREND: 'afterend',\n BEFOREBEGIN: 'beforebegin',\n BEFOREEND: 'beforeend'\n};\n\n\n/**\n * Inserts known-safe HTML into a Node, at the specified position.\n * @param {!Node} node The node on which to call insertAdjacentHTML.\n * @param {!goog.dom.safe.InsertAdjacentHtmlPosition} position Position where\n * to insert the HTML.\n * @param {!goog.html.SafeHtml} html The known-safe HTML to insert.\n */\ngoog.dom.safe.insertAdjacentHtml = function(node, position, html) {\n node.insertAdjacentHTML(position, goog.html.SafeHtml.unwrapTrustedHTML(html));\n};\n\n\n/**\n * Tags not allowed in goog.dom.safe.setInnerHtml.\n * @private @const {!Object<string, boolean>}\n */\ngoog.dom.safe.SET_INNER_HTML_DISALLOWED_TAGS_ = {\n 'MATH': true,\n 'SCRIPT': true,\n 'STYLE': true,\n 'SVG': true,\n 'TEMPLATE': true\n};\n\n\n/**\n * Whether assigning to innerHTML results in a non-spec-compliant clean-up. Used\n * to define goog.dom.safe.unsafeSetInnerHtmlDoNotUseOrElse.\n *\n * <p>As mentioned in https://stackoverflow.com/questions/28741528, re-rendering\n * an element in IE by setting innerHTML causes IE to recursively disconnect all\n * parent/children connections that were in the previous contents of the\n * element. Unfortunately, this can unexpectedly result in confusing cases where\n * a function is run (typically asynchronously) on element that has since\n * disconnected from the DOM but assumes the presence of its children. A simple\n * workaround is to remove all children first. Testing on IE11 via\n * https://jsperf.com/innerhtml-vs-removechild/239, removeChild seems to be\n * ~10x faster than innerHTML='' for a large number of children (perhaps due\n * to the latter's recursive behavior), implying that this workaround would\n * not hurt performance and might actually improve it.\n * @return {boolean}\n * @private\n */\ngoog.dom.safe.isInnerHtmlCleanupRecursive_ =\n goog.functions.cacheReturnValue(function() {\n // `document` missing in some test frameworks.\n if (goog.DEBUG && typeof document === 'undefined') {\n return false;\n }\n // Create 3 nested <div>s without using innerHTML.\n // We're not chaining the appendChilds in one call, as this breaks\n // in a DocumentFragment.\n var div = document.createElement('div');\n var childDiv = document.createElement('div');\n childDiv.appendChild(document.createElement('div'));\n div.appendChild(childDiv);\n // `firstChild` is null in Google Js Test.\n if (goog.DEBUG && !div.firstChild) {\n return false;\n }\n var innerChild = div.firstChild.firstChild;\n div.innerHTML =\n goog.html.SafeHtml.unwrapTrustedHTML(goog.html.SafeHtml.EMPTY);\n return !innerChild.parentElement;\n });\n\n\n/**\n * Assigns HTML to an element's innerHTML property. Helper to use only here and\n * in soy.js.\n * @param {?Element} elem The element whose innerHTML is to be assigned to.\n * @param {!goog.html.SafeHtml} html\n */\ngoog.dom.safe.unsafeSetInnerHtmlDoNotUseOrElse = function(elem, html) {\n // See comment above goog.dom.safe.isInnerHtmlCleanupRecursive_.\n if (goog.dom.safe.isInnerHtmlCleanupRecursive_()) {\n while (elem.lastChild) {\n elem.removeChild(elem.lastChild);\n }\n }\n elem.innerHTML = goog.html.SafeHtml.unwrapTrustedHTML(html);\n};\n\n\n/**\n * Assigns known-safe HTML to an element's innerHTML property.\n * @param {!Element} elem The element whose innerHTML is to be assigned to.\n * @param {!goog.html.SafeHtml} html The known-safe HTML to assign.\n * @throws {Error} If called with one of these tags: math, script, style, svg,\n * template.\n */\ngoog.dom.safe.setInnerHtml = function(elem, html) {\n if (goog.asserts.ENABLE_ASSERTS) {\n var tagName = elem.tagName.toUpperCase();\n if (goog.dom.safe.SET_INNER_HTML_DISALLOWED_TAGS_[tagName]) {\n throw new Error(\n 'goog.dom.safe.setInnerHtml cannot be used to set content of ' +\n elem.tagName + '.');\n }\n }\n\n goog.dom.safe.unsafeSetInnerHtmlDoNotUseOrElse(elem, html);\n};\n\n\n/**\n * Assigns known-safe HTML to an element's outerHTML property.\n * @param {!Element} elem The element whose outerHTML is to be assigned to.\n * @param {!goog.html.SafeHtml} html The known-safe HTML to assign.\n */\ngoog.dom.safe.setOuterHtml = function(elem, html) {\n elem.outerHTML = goog.html.SafeHtml.unwrapTrustedHTML(html);\n};\n\n\n/**\n * Safely assigns a URL a form element's action property.\n *\n * If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to\n * form's action property. If url is of type string however, it is first\n * sanitized using goog.html.SafeUrl.sanitize.\n *\n * Example usage:\n * goog.dom.safe.setFormElementAction(formEl, url);\n * which is a safe alternative to\n * formEl.action = url;\n * The latter can result in XSS vulnerabilities if url is a\n * user-/attacker-controlled value.\n *\n * @param {!Element} form The form element whose action property\n * is to be assigned to.\n * @param {string|!goog.html.SafeUrl} url The URL to assign.\n * @see goog.html.SafeUrl#sanitize\n */\ngoog.dom.safe.setFormElementAction = function(form, url) {\n /** @type {!goog.html.SafeUrl} */\n var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n goog.dom.asserts.assertIsHTMLFormElement(form).action =\n goog.html.SafeUrl.unwrap(safeUrl);\n};\n\n/**\n * Safely assigns a URL to a button element's formaction property.\n *\n * If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to\n * button's formaction property. If url is of type string however, it is first\n * sanitized using goog.html.SafeUrl.sanitize.\n *\n * Example usage:\n * goog.dom.safe.setButtonFormAction(buttonEl, url);\n * which is a safe alternative to\n * buttonEl.action = url;\n * The latter can result in XSS vulnerabilities if url is a\n * user-/attacker-controlled value.\n *\n * @param {!Element} button The button element whose action property\n * is to be assigned to.\n * @param {string|!goog.html.SafeUrl} url The URL to assign.\n * @see goog.html.SafeUrl#sanitize\n */\ngoog.dom.safe.setButtonFormAction = function(button, url) {\n /** @type {!goog.html.SafeUrl} */\n var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n goog.dom.asserts.assertIsHTMLButtonElement(button).formAction =\n goog.html.SafeUrl.unwrap(safeUrl);\n};\n/**\n * Safely assigns a URL to an input element's formaction property.\n *\n * If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to\n * input's formaction property. If url is of type string however, it is first\n * sanitized using goog.html.SafeUrl.sanitize.\n *\n * Example usage:\n * goog.dom.safe.setInputFormAction(inputEl, url);\n * which is a safe alternative to\n * inputEl.action = url;\n * The latter can result in XSS vulnerabilities if url is a\n * user-/attacker-controlled value.\n *\n * @param {!Element} input The input element whose action property\n * is to be assigned to.\n * @param {string|!goog.html.SafeUrl} url The URL to assign.\n * @see goog.html.SafeUrl#sanitize\n */\ngoog.dom.safe.setInputFormAction = function(input, url) {\n /** @type {!goog.html.SafeUrl} */\n var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n goog.dom.asserts.assertIsHTMLInputElement(input).formAction =\n goog.html.SafeUrl.unwrap(safeUrl);\n};\n\n/**\n * Sets the given element's style property to the contents of the provided\n * SafeStyle object.\n * @param {!Element} elem\n * @param {!goog.html.SafeStyle} style\n */\ngoog.dom.safe.setStyle = function(elem, style) {\n elem.style.cssText = goog.html.SafeStyle.unwrap(style);\n};\n\n\n/**\n * Writes known-safe HTML to a document.\n * @param {!Document} doc The document to be written to.\n * @param {!goog.html.SafeHtml} html The known-safe HTML to assign.\n */\ngoog.dom.safe.documentWrite = function(doc, html) {\n doc.write(goog.html.SafeHtml.unwrapTrustedHTML(html));\n};\n\n\n/**\n * Safely assigns a URL to an anchor element's href property.\n *\n * If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to\n * anchor's href property. If url is of type string however, it is first\n * sanitized using goog.html.SafeUrl.sanitize.\n *\n * Example usage:\n * goog.dom.safe.setAnchorHref(anchorEl, url);\n * which is a safe alternative to\n * anchorEl.href = url;\n * The latter can result in XSS vulnerabilities if url is a\n * user-/attacker-controlled value.\n *\n * @param {!HTMLAnchorElement} anchor The anchor element whose href property\n * is to be assigned to.\n * @param {string|!goog.html.SafeUrl} url The URL to assign.\n * @see goog.html.SafeUrl#sanitize\n */\ngoog.dom.safe.setAnchorHref = function(anchor, url) {\n goog.dom.asserts.assertIsHTMLAnchorElement(anchor);\n /** @type {!goog.html.SafeUrl} */\n var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n anchor.href = goog.html.SafeUrl.unwrap(safeUrl);\n};\n\n\n/**\n * Safely assigns a URL to an image element's src property.\n *\n * If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to\n * image's src property. If url is of type string however, it is first\n * sanitized using goog.html.SafeUrl.sanitize.\n *\n * @param {!HTMLImageElement} imageElement The image element whose src property\n * is to be assigned to.\n * @param {string|!goog.html.SafeUrl} url The URL to assign.\n * @see goog.html.SafeUrl#sanitize\n */\ngoog.dom.safe.setImageSrc = function(imageElement, url) {\n goog.dom.asserts.assertIsHTMLImageElement(imageElement);\n /** @type {!goog.html.SafeUrl} */\n var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n var allowDataUrl = /^data:image\\//i.test(url);\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url, allowDataUrl);\n }\n imageElement.src = goog.html.SafeUrl.unwrap(safeUrl);\n};\n\n/**\n * Safely assigns a URL to a audio element's src property.\n *\n * If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to\n * audio's src property. If url is of type string however, it is first\n * sanitized using goog.html.SafeUrl.sanitize.\n *\n * @param {!HTMLAudioElement} audioElement The audio element whose src property\n * is to be assigned to.\n * @param {string|!goog.html.SafeUrl} url The URL to assign.\n * @see goog.html.SafeUrl#sanitize\n */\ngoog.dom.safe.setAudioSrc = function(audioElement, url) {\n goog.dom.asserts.assertIsHTMLAudioElement(audioElement);\n /** @type {!goog.html.SafeUrl} */\n var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n var allowDataUrl = /^data:audio\\//i.test(url);\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url, allowDataUrl);\n }\n audioElement.src = goog.html.SafeUrl.unwrap(safeUrl);\n};\n\n/**\n * Safely assigns a URL to a video element's src property.\n *\n * If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to\n * video's src property. If url is of type string however, it is first\n * sanitized using goog.html.SafeUrl.sanitize.\n *\n * @param {!HTMLVideoElement} videoElement The video element whose src property\n * is to be assigned to.\n * @param {string|!goog.html.SafeUrl} url The URL to assign.\n * @see goog.html.SafeUrl#sanitize\n */\ngoog.dom.safe.setVideoSrc = function(videoElement, url) {\n goog.dom.asserts.assertIsHTMLVideoElement(videoElement);\n /** @type {!goog.html.SafeUrl} */\n var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n var allowDataUrl = /^data:video\\//i.test(url);\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url, allowDataUrl);\n }\n videoElement.src = goog.html.SafeUrl.unwrap(safeUrl);\n};\n\n/**\n * Safely assigns a URL to an embed element's src property.\n *\n * Example usage:\n * goog.dom.safe.setEmbedSrc(embedEl, url);\n * which is a safe alternative to\n * embedEl.src = url;\n * The latter can result in loading untrusted code unless it is ensured that\n * the URL refers to a trustworthy resource.\n *\n * @param {!HTMLEmbedElement} embed The embed element whose src property\n * is to be assigned to.\n * @param {!goog.html.TrustedResourceUrl} url The URL to assign.\n */\ngoog.dom.safe.setEmbedSrc = function(embed, url) {\n goog.dom.asserts.assertIsHTMLEmbedElement(embed);\n embed.src = goog.html.TrustedResourceUrl.unwrapTrustedScriptURL(url);\n};\n\n\n/**\n * Safely assigns a URL to a frame element's src property.\n *\n * Example usage:\n * goog.dom.safe.setFrameSrc(frameEl, url);\n * which is a safe alternative to\n * frameEl.src = url;\n * The latter can result in loading untrusted code unless it is ensured that\n * the URL refers to a trustworthy resource.\n *\n * @param {!HTMLFrameElement} frame The frame element whose src property\n * is to be assigned to.\n * @param {!goog.html.TrustedResourceUrl} url The URL to assign.\n */\ngoog.dom.safe.setFrameSrc = function(frame, url) {\n goog.dom.asserts.assertIsHTMLFrameElement(frame);\n frame.src = goog.html.TrustedResourceUrl.unwrap(url);\n};\n\n\n/**\n * Safely assigns a URL to an iframe element's src property.\n *\n * Example usage:\n * goog.dom.safe.setIframeSrc(iframeEl, url);\n * which is a safe alternative to\n * iframeEl.src = url;\n * The latter can result in loading untrusted code unless it is ensured that\n * the URL refers to a trustworthy resource.\n *\n * @param {!HTMLIFrameElement} iframe The iframe element whose src property\n * is to be assigned to.\n * @param {!goog.html.TrustedResourceUrl} url The URL to assign.\n */\ngoog.dom.safe.setIframeSrc = function(iframe, url) {\n goog.dom.asserts.assertIsHTMLIFrameElement(iframe);\n iframe.src = goog.html.TrustedResourceUrl.unwrap(url);\n};\n\n\n/**\n * Safely assigns HTML to an iframe element's srcdoc property.\n *\n * Example usage:\n * goog.dom.safe.setIframeSrcdoc(iframeEl, safeHtml);\n * which is a safe alternative to\n * iframeEl.srcdoc = html;\n * The latter can result in loading untrusted code.\n *\n * @param {!HTMLIFrameElement} iframe The iframe element whose srcdoc property\n * is to be assigned to.\n * @param {!goog.html.SafeHtml} html The HTML to assign.\n */\ngoog.dom.safe.setIframeSrcdoc = function(iframe, html) {\n goog.dom.asserts.assertIsHTMLIFrameElement(iframe);\n iframe.srcdoc = goog.html.SafeHtml.unwrapTrustedHTML(html);\n};\n\n\n/**\n * Safely sets a link element's href and rel properties. Whether or not\n * the URL assigned to href has to be a goog.html.TrustedResourceUrl\n * depends on the value of the rel property. If rel contains \"stylesheet\"\n * then a TrustedResourceUrl is required.\n *\n * Example usage:\n * goog.dom.safe.setLinkHrefAndRel(linkEl, url, 'stylesheet');\n * which is a safe alternative to\n * linkEl.rel = 'stylesheet';\n * linkEl.href = url;\n * The latter can result in loading untrusted code unless it is ensured that\n * the URL refers to a trustworthy resource.\n *\n * @param {!HTMLLinkElement} link The link element whose href property\n * is to be assigned to.\n * @param {string|!goog.html.SafeUrl|!goog.html.TrustedResourceUrl} url The URL\n * to assign to the href property. Must be a TrustedResourceUrl if the\n * value assigned to rel contains \"stylesheet\". A string value is\n * sanitized with goog.html.SafeUrl.sanitize.\n * @param {string} rel The value to assign to the rel property.\n * @throws {Error} if rel contains \"stylesheet\" and url is not a\n * TrustedResourceUrl\n * @see goog.html.SafeUrl#sanitize\n */\ngoog.dom.safe.setLinkHrefAndRel = function(link, url, rel) {\n goog.dom.asserts.assertIsHTMLLinkElement(link);\n link.rel = rel;\n if (goog.string.internal.caseInsensitiveContains(rel, 'stylesheet')) {\n goog.asserts.assert(\n url instanceof goog.html.TrustedResourceUrl,\n 'URL must be TrustedResourceUrl because \"rel\" contains \"stylesheet\"');\n link.href = goog.html.TrustedResourceUrl.unwrap(url);\n } else if (url instanceof goog.html.TrustedResourceUrl) {\n link.href = goog.html.TrustedResourceUrl.unwrap(url);\n } else if (url instanceof goog.html.SafeUrl) {\n link.href = goog.html.SafeUrl.unwrap(url);\n } else { // string\n // SafeUrl.sanitize must return legitimate SafeUrl when passed a string.\n link.href = goog.html.SafeUrl.unwrap(\n goog.html.SafeUrl.sanitizeAssertUnchanged(url));\n }\n};\n\n\n/**\n * Safely assigns a URL to an object element's data property.\n *\n * Example usage:\n * goog.dom.safe.setObjectData(objectEl, url);\n * which is a safe alternative to\n * objectEl.data = url;\n * The latter can result in loading untrusted code unless setit is ensured that\n * the URL refers to a trustworthy resource.\n *\n * @param {!HTMLObjectElement} object The object element whose data property\n * is to be assigned to.\n * @param {!goog.html.TrustedResourceUrl} url The URL to assign.\n */\ngoog.dom.safe.setObjectData = function(object, url) {\n goog.dom.asserts.assertIsHTMLObjectElement(object);\n object.data = goog.html.TrustedResourceUrl.unwrapTrustedScriptURL(url);\n};\n\n\n/**\n * Safely assigns a URL to a script element's src property.\n *\n * Example usage:\n * goog.dom.safe.setScriptSrc(scriptEl, url);\n * which is a safe alternative to\n * scriptEl.src = url;\n * The latter can result in loading untrusted code unless it is ensured that\n * the URL refers to a trustworthy resource.\n *\n * @param {!HTMLScriptElement} script The script element whose src property\n * is to be assigned to.\n * @param {!goog.html.TrustedResourceUrl} url The URL to assign.\n */\ngoog.dom.safe.setScriptSrc = function(script, url) {\n goog.dom.asserts.assertIsHTMLScriptElement(script);\n script.src = goog.html.TrustedResourceUrl.unwrapTrustedScriptURL(url);\n\n // If CSP nonces are used, propagate them to dynamically created scripts.\n // This is necessary to allow nonce-based CSPs without 'strict-dynamic'.\n var nonce = goog.getScriptNonce();\n if (nonce) {\n script.setAttribute('nonce', nonce);\n }\n};\n\n\n/**\n * Safely assigns a value to a script element's content.\n *\n * Example usage:\n * goog.dom.safe.setScriptContent(scriptEl, content);\n * which is a safe alternative to\n * scriptEl.text = content;\n * The latter can result in executing untrusted code unless it is ensured that\n * the code is loaded from a trustworthy resource.\n *\n * @param {!HTMLScriptElement} script The script element whose content is being\n * set.\n * @param {!goog.html.SafeScript} content The content to assign.\n */\ngoog.dom.safe.setScriptContent = function(script, content) {\n goog.dom.asserts.assertIsHTMLScriptElement(script);\n script.text = goog.html.SafeScript.unwrapTrustedScript(content);\n\n // If CSP nonces are used, propagate them to dynamically created scripts.\n // This is necessary to allow nonce-based CSPs without 'strict-dynamic'.\n var nonce = goog.getScriptNonce();\n if (nonce) {\n script.setAttribute('nonce', nonce);\n }\n};\n\n\n/**\n * Safely assigns a URL to a Location object's href property.\n *\n * If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to\n * loc's href property. If url is of type string however, it is first sanitized\n * using goog.html.SafeUrl.sanitize.\n *\n * Example usage:\n * goog.dom.safe.setLocationHref(document.location, redirectUrl);\n * which is a safe alternative to\n * document.location.href = redirectUrl;\n * The latter can result in XSS vulnerabilities if redirectUrl is a\n * user-/attacker-controlled value.\n *\n * @param {!Location} loc The Location object whose href property is to be\n * assigned to.\n * @param {string|!goog.html.SafeUrl} url The URL to assign.\n * @see goog.html.SafeUrl#sanitize\n */\ngoog.dom.safe.setLocationHref = function(loc, url) {\n goog.dom.asserts.assertIsLocation(loc);\n /** @type {!goog.html.SafeUrl} */\n var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n loc.href = goog.html.SafeUrl.unwrap(safeUrl);\n};\n\n/**\n * Safely assigns the URL of a Location object.\n *\n * If url is of type goog.html.SafeUrl, its value is unwrapped and\n * passed to Location#assign. If url is of type string however, it is\n * first sanitized using goog.html.SafeUrl.sanitize.\n *\n * Example usage:\n * goog.dom.safe.assignLocation(document.location, newUrl);\n * which is a safe alternative to\n * document.location.assign(newUrl);\n * The latter can result in XSS vulnerabilities if newUrl is a\n * user-/attacker-controlled value.\n *\n * This has the same behaviour as setLocationHref, however some test\n * mock Location.assign instead of a property assignment.\n *\n * @param {!Location} loc The Location object which is to be assigned.\n * @param {string|!goog.html.SafeUrl} url The URL to assign.\n * @see goog.html.SafeUrl#sanitize\n */\ngoog.dom.safe.assignLocation = function(loc, url) {\n goog.dom.asserts.assertIsLocation(loc);\n /** @type {!goog.html.SafeUrl} */\n var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n loc.assign(goog.html.SafeUrl.unwrap(safeUrl));\n};\n\n\n/**\n * Safely replaces the URL of a Location object.\n *\n * If url is of type goog.html.SafeUrl, its value is unwrapped and\n * passed to Location#replace. If url is of type string however, it is\n * first sanitized using goog.html.SafeUrl.sanitize.\n *\n * Example usage:\n * goog.dom.safe.replaceLocation(document.location, newUrl);\n * which is a safe alternative to\n * document.location.replace(newUrl);\n * The latter can result in XSS vulnerabilities if newUrl is a\n * user-/attacker-controlled value.\n *\n * @param {!Location} loc The Location object which is to be replaced.\n * @param {string|!goog.html.SafeUrl} url The URL to assign.\n * @see goog.html.SafeUrl#sanitize\n */\ngoog.dom.safe.replaceLocation = function(loc, url) {\n goog.dom.asserts.assertIsLocation(loc);\n /** @type {!goog.html.SafeUrl} */\n var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n loc.replace(goog.html.SafeUrl.unwrap(safeUrl));\n};\n\n\n/**\n * Safely opens a URL in a new window (via window.open).\n *\n * If url is of type goog.html.SafeUrl, its value is unwrapped and passed in to\n * window.open. If url is of type string however, it is first sanitized\n * using goog.html.SafeUrl.sanitize.\n *\n * Note that this function does not prevent leakages via the referer that is\n * sent by window.open. It is advised to only use this to open 1st party URLs.\n *\n * Example usage:\n * goog.dom.safe.openInWindow(url);\n * which is a safe alternative to\n * window.open(url);\n * The latter can result in XSS vulnerabilities if redirectUrl is a\n * user-/attacker-controlled value.\n *\n * @param {string|!goog.html.SafeUrl} url The URL to open.\n * @param {Window=} opt_openerWin Window of which to call the .open() method.\n * Defaults to the global window.\n * @param {!goog.string.Const=} opt_name Name of the window to open in. Can be\n * _top, etc as allowed by window.open().\n * @param {string=} opt_specs Comma-separated list of specifications, same as\n * in window.open().\n * @param {boolean=} opt_replace Whether to replace the current entry in browser\n * history, same as in window.open().\n * @return {Window} Window the url was opened in.\n */\ngoog.dom.safe.openInWindow = function(\n url, opt_openerWin, opt_name, opt_specs, opt_replace) {\n /** @type {!goog.html.SafeUrl} */\n var safeUrl;\n if (url instanceof goog.html.SafeUrl) {\n safeUrl = url;\n } else {\n safeUrl = goog.html.SafeUrl.sanitizeAssertUnchanged(url);\n }\n var win = opt_openerWin || goog.global;\n return win.open(\n goog.html.SafeUrl.unwrap(safeUrl),\n // If opt_name is undefined, simply passing that in to open() causes IE to\n // reuse the current window instead of opening a new one. Thus we pass ''\n // in instead, which according to spec opens a new window. See\n // https://html.spec.whatwg.org/multipage/browsers.html#dom-open .\n opt_name ? goog.string.Const.unwrap(opt_name) : '', opt_specs,\n opt_replace);\n};\n\n\n/**\n * Parses the HTML as 'text/html'.\n * @param {!DOMParser} parser\n * @param {!goog.html.SafeHtml} html The HTML to be parsed.\n * @return {?Document}\n */\ngoog.dom.safe.parseFromStringHtml = function(parser, html) {\n return goog.dom.safe.parseFromString(parser, html, 'text/html');\n};\n\n\n/**\n * Parses the string.\n * @param {!DOMParser} parser\n * @param {!goog.html.SafeHtml} content Note: We don't have a special type for\n * XML od SVG supported by this function so we use SafeHtml.\n * @param {string} type\n * @return {?Document}\n */\ngoog.dom.safe.parseFromString = function(parser, content, type) {\n return parser.parseFromString(\n goog.html.SafeHtml.unwrapTrustedHTML(content), type);\n};\n\n\n/**\n * Safely creates an HTMLImageElement from a Blob.\n *\n * Example usage:\n * goog.dom.safe.createImageFromBlob(blob);\n * which is a safe alternative to\n * image.src = createObjectUrl(blob)\n * The latter can result in executing malicious same-origin scripts from a bad\n * Blob.\n * @param {!Blob} blob The blob to create the image from.\n * @return {!HTMLImageElement} The image element created from the blob.\n * @throws {!Error} If called with a Blob with a MIME type other than image/.*.\n */\ngoog.dom.safe.createImageFromBlob = function(blob) {\n // Any image/* MIME type is accepted as safe.\n if (!/^image\\/.*/g.test(blob.type)) {\n throw new Error(\n 'goog.dom.safe.createImageFromBlob only accepts MIME type image/.*.');\n }\n var objectUrl = goog.global.URL.createObjectURL(blob);\n var image = new goog.global.Image();\n image.onload = function() {\n goog.global.URL.revokeObjectURL(objectUrl);\n };\n goog.dom.safe.setImageSrc(\n image,\n goog.html.uncheckedconversions\n .safeUrlFromStringKnownToSatisfyTypeContract(\n goog.string.Const.from('Image blob URL.'), objectUrl));\n return image;\n};\n","~:compiled-at",1584073468448,"~:source-map-json","{\n\"version\":3,\n\"file\":\"goog.dom.safe.js\",\n\"lineCount\":370,\n\"mappings\":\"AAuCAA,IAAAC,QAAA,CAAa,eAAb,CAAA;AACAD,IAAAC,QAAA,CAAa,0CAAb,CAAA;AAEAD,IAAAE,QAAA,CAAa,cAAb,CAAA;AACAF,IAAAE,QAAA,CAAa,kBAAb,CAAA;AACAF,IAAAE,QAAA,CAAa,gBAAb,CAAA;AACAF,IAAAE,QAAA,CAAa,oBAAb,CAAA;AACAF,IAAAE,QAAA,CAAa,sBAAb,CAAA;AACAF,IAAAE,QAAA,CAAa,qBAAb,CAAA;AACAF,IAAAE,QAAA,CAAa,mBAAb,CAAA;AACAF,IAAAE,QAAA,CAAa,8BAAb,CAAA;AACAF,IAAAE,QAAA,CAAa,gCAAb,CAAA;AACAF,IAAAE,QAAA,CAAa,mBAAb,CAAA;AACAF,IAAAE,QAAA,CAAa,sBAAb,CAAA;AAIA,sBAAAF,IAAAG,IAAAC,KAAAC,2BAAA,GAA2C,CACzCC,WAAY,YAD6B,EAEzCC,SAAU,UAF+B,EAGzCC,YAAa,aAH4B,EAIzCC,UAAW,WAJ8B,CAA3C;AAeA;;;;;AAAAT,IAAAG,IAAAC,KAAAM,mBAAA,GAAmCC,QA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