-
Notifications
You must be signed in to change notification settings - Fork 8
dont escape prop and attribute values #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
<script async="" type="application/javascript" src="chunks/defaultVendors~main-063769ad5d827b791041.js"></script>
but should <script async="" type="application/javascript" src="chunks/defaultVendors~main-063769ad5d827b791041.js"></script>
@thomashoneyman can I be added to org? |
Add srghma to org please, he makes good code 👍 |
It might not be escaping correctly just now but they definitely need to be escaped too, otherwise the result will be syntactically invalid when there's a |
so, probably suffers from same issue too |
@garyb escapeRegex ∷ Regex
escapeRegex = unsafeRegex "[\\\"\\\'/&<>]" global
escapeChar ∷ String → String
escapeChar = case _ of
"/" → "/"
ch → escapeCharExceptSlash ch
escape ∷ String → String
escape = replace' escapeRegex (const <<< escapeChar)
----------
escapeRegexExceptSlash ∷ Regex
escapeRegexExceptSlash = unsafeRegex "[\\\"\\\'&<>]" global
escapeCharExceptSlash ∷ String → String
escapeCharExceptSlash = case _ of
"\"" → """
"'" → "'"
"&" → "&"
"<" → "<"
">" → ">"
ch → ch
escapeExceptSlash ∷ String → String
escapeExceptSlash = replace' escapeRegexExceptSlash (const <<< escapeCharExceptSlash)
----------
IF node == "script" && prop = "type" THEN escapeAllExceptSlash value ELSE escapeHTML value Proposal 2: always use |
…src="chunks/defaultVendors~main-063769ad5d827b791041.js"></script>` but should `<script async="" type="application/javascript" src="chunks/defaultVendors~main-063769ad5d827b791041.js"></script>`
…on>` -> dont render prop at all if it is a boolean and is false (this commit matches purescript-halogen/purescript-halogen-vdom@cfd471e)
TODO: jsdom uses: attr value - https://github.com/jsdom/w3c-xmlserializer/blob/83115f8ecce8ed77a2a907c74407b2c671751463/lib/attributes.js#L24-L37 |
config =
[ { char: "\"", charName: "double quotes", escapedChar: """, elementName: true, attrName: true, attrValue: true, propName: true, propValue: true }
, { char: "'", charName: "single quotes", escapedChar: "'", elementName: true, attrName: true, attrValue: true, propName: true, propValue: true }
, { char: "/", charName: "slash", escapedChar: "/", elementName: true, attrName: true, attrValue: true, propName: true, propValue: true }
, { char: "\\", charName: "backslash", escapedChar: "", elementName: true, attrName: true, attrValue: true, propName: true, propValue: true }
, { char: "&", charName: "ampersand", escapedChar: "&", elementName: true, attrName: true, attrValue: true, propName: true, propValue: true }
, { char: "<", charName: "less than", escapedChar: "<", elementName: true, attrName: true, attrValue: true, propName: true, propValue: true }
, { char: ">", charName: "more than", escapedChar: ">", elementName: true, attrName: true, attrValue: true, propName: true, propValue: true }
, { char: "\t", charName: "tab", escapedChar: "	", elementName: true, attrName: true, attrValue: true, propName: true, propValue: true }
, { char: "\n", charName: "newline", escapedChar: "
", elementName: true, attrName: true, attrValue: true, propName: true, propValue: true }
, { char: "\r", charName: "r", escapedChar: "
", elementName: true, attrName: true, attrValue: true, propName: true, propValue: true }
, { char: "", charName: "", escapedChar: "
", elementName: true, attrName: true, attrValue: true, propName: true, propValue: true }
]
config.forEach(x => { try { document.createElement(div${x.char}) } catch (e) { console.error(e)} }) // all are invalid names
VM291:15 InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('div"') is not a valid name.
at <anonymous>:15:44
at Array.forEach (<anonymous>)
at <anonymous>:15:14
overrideMethod @ hook.js:608
(anonymous) @ VM291:15
(anonymous) @ VM291:15Understand this errorAI
VM291:15 InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('div'') is not a valid name.
at <anonymous>:15:44
at Array.forEach (<anonymous>)
at <anonymous>:15:14
overrideMethod @ hook.js:608
(anonymous) @ VM291:15
(anonymous) @ VM291:15Understand this errorAI
VM291:15 InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('div/') is not a valid name.
at <anonymous>:15:44
at Array.forEach (<anonymous>)
at <anonymous>:15:14
overrideMethod @ hook.js:608
(anonymous) @ VM291:15
(anonymous) @ VM291:15Understand this errorAI
VM291:15 InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('div\') is not a valid name.
at <anonymous>:15:44
at Array.forEach (<anonymous>)
at <anonymous>:15:14
overrideMethod @ hook.js:608
(anonymous) @ VM291:15
(anonymous) @ VM291:15Understand this errorAI
VM291:15 InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('div&') is not a valid name.
at <anonymous>:15:44
at Array.forEach (<anonymous>)
at <anonymous>:15:14
overrideMethod @ hook.js:608
(anonymous) @ VM291:15
(anonymous) @ VM291:15Understand this errorAI
VM291:15 InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('div<') is not a valid name.
at <anonymous>:15:44
at Array.forEach (<anonymous>)
at <anonymous>:15:14
overrideMethod @ hook.js:608
(anonymous) @ VM291:15
(anonymous) @ VM291:15Understand this errorAI
VM291:15 InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('div>') is not a valid name.
at <anonymous>:15:44
at Array.forEach (<anonymous>)
at <anonymous>:15:14
overrideMethod @ hook.js:608
(anonymous) @ VM291:15
(anonymous) @ VM291:15Understand this errorAI
VM291:15 InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('div ') is not a valid name.
at <anonymous>:15:44
at Array.forEach (<anonymous>)
at <anonymous>:15:14
overrideMethod @ hook.js:608
(anonymous) @ VM291:15
(anonymous) @ VM291:15Understand this errorAI
VM291:15 InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('div
') is not a valid name.
at <anonymous>:15:44
at Array.forEach (<anonymous>)
at <anonymous>:15:14
overrideMethod @ hook.js:608
(anonymous) @ VM291:15
(anonymous) @ VM291:15Understand this errorAI
VM291:15 InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('div
') is not a valid name.
at <anonymous>:15:44
at Array.forEach (<anonymous>)
at <anonymous>:15:14
overrideMethod @ hook.js:608
(anonymous) @ VM291:15
(anonymous) @ VM291:15Understand this errorAI
VM291:15 InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('div') is not a valid name.
at <anonymous>:15:44
at Array.forEach (<anonymous>)
at <anonymous>:15:14 so, we need to add https://github.com/jsdom/xml-name-validator/blob/836f307eec81279d2b1655587892e38a1effe039/lib/xml-name-validator.js#L4 to
P.S. ✅
|
…attr name is invlaid - we ignore invalid chars) (NOTE: we could just use he npm package to escape all, no ignoring/cleaning)
I have added more functionality, but escapeHtmlEntity function doesnt escape everything possible (we could use he package to escape all), and instead of |
No description provided.