angular-html-parser
Advanced tools
@@ -229,4 +229,4 @@ import { TagContentType, mergeNsAndName } from "./tags.mjs"; | ||
| this._beginToken(TokenType.LET_END); | ||
| this._cursor.advance(); | ||
| this._endToken([]); | ||
| this._cursor.advance(); | ||
| } else { | ||
@@ -233,0 +233,0 @@ startToken.type = TokenType.INCOMPLETE_LET; |
@@ -443,3 +443,3 @@ import { getNsPrefix, mergeNsAndName, splitNsName } from "./tags.mjs"; | ||
| } else endToken = this._advance(); | ||
| const end = endToken.sourceSpan.fullStart; | ||
| const end = endToken.sourceSpan.end; | ||
| const span = new ParseSourceSpan(startToken.sourceSpan.start, end, startToken.sourceSpan.fullStart); | ||
@@ -446,0 +446,0 @@ const startOffset = startToken.sourceSpan.toString().lastIndexOf(name); |
@@ -376,6 +376,4 @@ import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SecurityContext } from "../core.mjs"; | ||
| propName = propName.toLowerCase(); | ||
| let ctx = SECURITY_SCHEMA()[tagName + "|" + propName]; | ||
| if (ctx) return ctx; | ||
| ctx = SECURITY_SCHEMA()["*|" + propName]; | ||
| return ctx ? ctx : SecurityContext.NONE; | ||
| const securitySchema = SECURITY_SCHEMA(); | ||
| return securitySchema[tagName + "|" + propName] ?? securitySchema["*|" + propName] ?? SecurityContext.NONE; | ||
| } | ||
@@ -382,0 +380,0 @@ getMappedPropName(propName) { |
@@ -12,131 +12,131 @@ import { SecurityContext } from "../core.mjs"; | ||
| let _SECURITY_SCHEMA; | ||
| const SVG_NAMESPACE = "svg"; | ||
| const MATH_ML_NAMESPACE = "math"; | ||
| function SECURITY_SCHEMA() { | ||
| if (!_SECURITY_SCHEMA) { | ||
| _SECURITY_SCHEMA = {}; | ||
| registerContext(SecurityContext.HTML, [ | ||
| "iframe|srcdoc", | ||
| "*|innerHTML", | ||
| "*|outerHTML" | ||
| registerContext( | ||
| SecurityContext.HTML, | ||
| /** Namespace */ | ||
| void 0, | ||
| [["iframe", ["srcdoc"]], ["*", ["innerHTML", "outerHTML"]]] | ||
| ); | ||
| registerContext( | ||
| SecurityContext.STYLE, | ||
| /** Namespace */ | ||
| void 0, | ||
| [["*", ["style"]]] | ||
| ); | ||
| registerContext( | ||
| SecurityContext.URL, | ||
| /** Namespace */ | ||
| void 0, | ||
| [ | ||
| ["*", ["formAction"]], | ||
| ["area", ["href"]], | ||
| ["a", ["href", "xlink:href"]], | ||
| ["form", ["action"]], | ||
| ["img", ["src"]], | ||
| ["video", ["src"]] | ||
| ] | ||
| ); | ||
| registerContext(SecurityContext.URL, MATH_ML_NAMESPACE, [ | ||
| ["annotation", ["href", "xlink:href"]], | ||
| ["annotation-xml", ["href", "xlink:href"]], | ||
| ["maction", ["href", "xlink:href"]], | ||
| ["malignmark", ["href", "xlink:href"]], | ||
| ["math", ["href", "xlink:href"]], | ||
| ["mroot", ["href", "xlink:href"]], | ||
| ["msqrt", ["href", "xlink:href"]], | ||
| ["merror", ["href", "xlink:href"]], | ||
| ["mfrac", ["href", "xlink:href"]], | ||
| ["mglyph", ["href", "xlink:href"]], | ||
| ["msub", ["href", "xlink:href"]], | ||
| ["msup", ["href", "xlink:href"]], | ||
| ["msubsup", ["href", "xlink:href"]], | ||
| ["mmultiscripts", ["href", "xlink:href"]], | ||
| ["mprescripts", ["href", "xlink:href"]], | ||
| ["mi", ["href", "xlink:href"]], | ||
| ["mn", ["href", "xlink:href"]], | ||
| ["mo", ["href", "xlink:href"]], | ||
| ["mpadded", ["href", "xlink:href"]], | ||
| ["mphantom", ["href", "xlink:href"]], | ||
| ["mrow", ["href", "xlink:href"]], | ||
| ["ms", ["href", "xlink:href"]], | ||
| ["mspace", ["href", "xlink:href"]], | ||
| ["mstyle", ["href", "xlink:href"]], | ||
| ["mtable", ["href", "xlink:href"]], | ||
| ["mtd", ["href", "xlink:href"]], | ||
| ["mtr", ["href", "xlink:href"]], | ||
| ["mtext", ["href", "xlink:href"]], | ||
| ["mover", ["href", "xlink:href"]], | ||
| ["munder", ["href", "xlink:href"]], | ||
| ["munderover", ["href", "xlink:href"]], | ||
| ["semantics", ["href", "xlink:href"]], | ||
| ["none", ["href", "xlink:href"]] | ||
| ]); | ||
| registerContext(SecurityContext.STYLE, ["*|style"]); | ||
| registerContext(SecurityContext.URL, [ | ||
| "*|formAction", | ||
| "area|href", | ||
| "a|href", | ||
| "a|xlink:href", | ||
| "form|action", | ||
| "annotation|href", | ||
| "annotation|xlink:href", | ||
| "annotation-xml|href", | ||
| "annotation-xml|xlink:href", | ||
| "maction|href", | ||
| "maction|xlink:href", | ||
| "malignmark|href", | ||
| "malignmark|xlink:href", | ||
| "math|href", | ||
| "math|xlink:href", | ||
| "mroot|href", | ||
| "mroot|xlink:href", | ||
| "msqrt|href", | ||
| "msqrt|xlink:href", | ||
| "merror|href", | ||
| "merror|xlink:href", | ||
| "mfrac|href", | ||
| "mfrac|xlink:href", | ||
| "mglyph|href", | ||
| "mglyph|xlink:href", | ||
| "msub|href", | ||
| "msub|xlink:href", | ||
| "msup|href", | ||
| "msup|xlink:href", | ||
| "msubsup|href", | ||
| "msubsup|xlink:href", | ||
| "mmultiscripts|href", | ||
| "mmultiscripts|xlink:href", | ||
| "mprescripts|href", | ||
| "mprescripts|xlink:href", | ||
| "mi|href", | ||
| "mi|xlink:href", | ||
| "mn|href", | ||
| "mn|xlink:href", | ||
| "mo|href", | ||
| "mo|xlink:href", | ||
| "mpadded|href", | ||
| "mpadded|xlink:href", | ||
| "mphantom|href", | ||
| "mphantom|xlink:href", | ||
| "mrow|href", | ||
| "mrow|xlink:href", | ||
| "ms|href", | ||
| "ms|xlink:href", | ||
| "mspace|href", | ||
| "mspace|xlink:href", | ||
| "mstyle|href", | ||
| "mstyle|xlink:href", | ||
| "mtable|href", | ||
| "mtable|xlink:href", | ||
| "mtd|href", | ||
| "mtd|xlink:href", | ||
| "mtr|href", | ||
| "mtr|xlink:href", | ||
| "mtext|href", | ||
| "mtext|xlink:href", | ||
| "mover|href", | ||
| "mover|xlink:href", | ||
| "munder|href", | ||
| "munder|xlink:href", | ||
| "munderover|href", | ||
| "munderover|xlink:href", | ||
| "semantics|href", | ||
| "semantics|xlink:href", | ||
| "none|href", | ||
| "none|xlink:href", | ||
| "img|src", | ||
| "video|src" | ||
| registerContext( | ||
| SecurityContext.RESOURCE_URL, | ||
| /** Namespace */ | ||
| void 0, | ||
| [ | ||
| ["base", ["href"]], | ||
| ["embed", ["src"]], | ||
| ["frame", ["src"]], | ||
| ["iframe", ["src"]], | ||
| ["link", ["href"]], | ||
| ["object", ["codebase", "data"]] | ||
| ] | ||
| ); | ||
| registerContext(SecurityContext.RESOURCE_URL, SVG_NAMESPACE, [["script", [ | ||
| "src", | ||
| "href", | ||
| "xlink:href" | ||
| ]]]); | ||
| registerContext(SecurityContext.ATTRIBUTE_NO_BINDING, SVG_NAMESPACE, [ | ||
| ["animate", [ | ||
| "attributeName", | ||
| "values", | ||
| "to", | ||
| "from" | ||
| ]], | ||
| ["set", ["to", "attributeName"]], | ||
| ["animateMotion", ["attributeName"]], | ||
| ["animateTransform", ["attributeName"]] | ||
| ]); | ||
| registerContext(SecurityContext.RESOURCE_URL, [ | ||
| "base|href", | ||
| "embed|src", | ||
| "frame|src", | ||
| "iframe|src", | ||
| "link|href", | ||
| "object|codebase", | ||
| "object|data", | ||
| "script|src", | ||
| "script|href", | ||
| "script|xlink:href" | ||
| ]); | ||
| registerContext(SecurityContext.ATTRIBUTE_NO_BINDING, [ | ||
| "animate|attributeName", | ||
| "animate|values", | ||
| "animate|to", | ||
| "animate|from", | ||
| "set|to", | ||
| "set|attributeName", | ||
| "animateMotion|attributeName", | ||
| "animateTransform|attributeName", | ||
| "unknown|attributeName", | ||
| "unknown|values", | ||
| "unknown|to", | ||
| "unknown|from", | ||
| "iframe|sandbox", | ||
| "iframe|allow", | ||
| "iframe|allowFullscreen", | ||
| "iframe|referrerPolicy", | ||
| "iframe|csp", | ||
| "iframe|fetchPriority", | ||
| "unknown|sandbox", | ||
| "unknown|allow", | ||
| "unknown|allowFullscreen", | ||
| "unknown|referrerPolicy", | ||
| "unknown|csp", | ||
| "unknown|fetchPriority" | ||
| ]); | ||
| registerContext( | ||
| SecurityContext.ATTRIBUTE_NO_BINDING, | ||
| /** Namespace */ | ||
| void 0, | ||
| [["unknown", [ | ||
| "attributeName", | ||
| "values", | ||
| "to", | ||
| "from", | ||
| "sandbox", | ||
| "allow", | ||
| "allowFullscreen", | ||
| "referrerPolicy", | ||
| "csp", | ||
| "fetchPriority" | ||
| ]], ["iframe", [ | ||
| "sandbox", | ||
| "allow", | ||
| "allowFullscreen", | ||
| "referrerPolicy", | ||
| "csp", | ||
| "fetchPriority" | ||
| ]]] | ||
| ); | ||
| } | ||
| return _SECURITY_SCHEMA; | ||
| } | ||
| function registerContext(ctx, specs) { | ||
| for (const spec of specs) _SECURITY_SCHEMA[spec.toLowerCase()] = ctx; | ||
| function registerContext(ctx, namespace, specs) { | ||
| for (const [element, attributeNames] of specs) { | ||
| let tagName = namespace && element !== "*" && element !== "unknown" ? `:${namespace}:${element}` : element; | ||
| tagName = tagName.toLowerCase(); | ||
| for (const attr of attributeNames) _SECURITY_SCHEMA[`${tagName}|${attr.toLowerCase()}`] = ctx; | ||
| } | ||
| } | ||
| //#endregion | ||
| export { SECURITY_SCHEMA }; |
+1
-1
| { | ||
| "name": "angular-html-parser", | ||
| "version": "10.5.0", | ||
| "version": "10.6.0", | ||
| "description": "A HTML parser extracted from Angular with some modifications", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/prettier/angular-html-parser", |
195666
0.32%5280
-0.04%