You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Low version browsers such as Chrome 109 may generate errors when setting illegal attribute names #283
The output of the large model is unstable and may output characters such as Alert {id="1""} with additional quotation marks, which can result in illegal attribute names and error messages in lower versions
Low version browsers such as Chrome 109 may generate errors when setting illegal attribute names
The 'is not a valid attribute name' in the error message refers to a single double quotation mark character. According to HTML standards, attribute names cannot contain characters such as', ',<,>,/,=, etc., so the browser directly throws a DOMException
I've also encountered a similar issue — whether illegal attributes and other formats can be intercepted to prevent the engine from freezing or crashing during stream parsing due to non-compliant formats. thank you very much!
Yes, I have used this PR code, but unfortunately it didn't resolve the issue I encountered. My goal is to ensure that no string stream input ever throws an error. If the content is not in Markdown format, output the original string. Thank you to the author—thank you so much, I really appreciate your hard work! Below is a summary of the cases I've personally compiled:
SAFE_ATTR_NAME_RE = /^:?[A-Za-z_][\w:.-]*$/
Attribute names that do not start with a letter or underscore (e.g., 123, -foo, .class)
Names containing characters other than alphanumeric, underscores, colons, dots, or hyphens (e.g., @click, #id, café, paths, 🚀)
Empty strings
Type and format checks in isValidAttrName (before regex)
name is null / undefined / not a string
name.trim() !== name (leading or trailing whitespace)
DOM createAttribute validation (after passing regex)
Attribute names that pass the above rules but still throw an InvalidCharacterError in the browser (e.g., xmlns:foo/bar)
Structural validation failures (non-regex, during full traversal)
Proxy ownKeys throws an exception → unable to enumerate keys → marked as kind: "attrs-inspection-failed", original object retained
Object is frozen/sealed and delete fails → reconstruct a prototype-free object
AST element node is not writable (tryReplaceAttrs returns false) → repaired: false, surviving illegal keys logged
Diagnostic log classification (display only, not for interception)
Pattern matching in classifyBadAttrReason():
/:/// or /^https?:/i → "URL/protocol string"
//\/ or /path\s*:/i or includes "{path" → "path fragment"
/[{}]/ → "curly brace residue"
/[@#$%^&*]/ → "special symbols"
/[\s"'<>=,]/ → "spaces/quotes/angle brackets/equals"
/[()[]|;]/ → "parentheses/vertical bar/semicolon"
/[^\x20-\x7E]/ → "non-ASCII"
!badAttr → "empty attribute name"
I believe what you are looking for is bit specific and not a general use. It would be great plugin for Comark.
I'll update the PR to make sure attributes start with a-z chars but other non-markdown streaming is too much for Comark core.
If the content is not in Markdown format, output the original string.
This is also not possible imagine having <div 3attr="value">, it is not possible to keep 3attr="value" as text while it is an attribute
Activity
rock53770 commentedon Jul 16, 2026
function isValidAttrName(name) {
try {
document.createAttribute(name)
return true
} catch {
return false
}
}
rock53770 commentedon Jul 17, 2026
It can be modified through plugins. Please close it first
pony04311 commentedon Jul 27, 2026
I've also encountered a similar issue — whether illegal attributes and other formats can be intercepted to prevent the engine from freezing or crashing during stream parsing due to non-compliant formats. thank you very much!
farnabaz commentedon Jul 28, 2026
This should be fixed in #298.
I appreciate if you can verify the fix
pony04311 commentedon Jul 29, 2026
Issues may still arise when encountering dirty data. Is it possible to resolve the exceptions caused by dirty data?
rock53770 commentedon Jul 29, 2026
Is it better to use this as each browser version supports different attributes?
farnabaz commentedon Jul 29, 2026
@pony04311 What you mean by dirty data? H
ave you tried the PR release?
pony04311 commentedon Jul 30, 2026
Yes, I have used this PR code, but unfortunately it didn't resolve the issue I encountered. My goal is to ensure that no string stream input ever throws an error. If the content is not in Markdown format, output the original string. Thank you to the author—thank you so much, I really appreciate your hard work! Below is a summary of the cases I've personally compiled:
SAFE_ATTR_NAME_RE = /^:?[A-Za-z_][\w:.-]*$/
Attribute names that do not start with a letter or underscore (e.g., 123, -foo, .class)
Names containing characters other than alphanumeric, underscores, colons, dots, or hyphens (e.g., @click, #id, café, paths, 🚀)
Empty strings
PUNCT_POISON_RE = /[/\'"<>\s=,(){}[]|;]|:///
Contains / (e.g., path:/etc/passwd, foo/bar)
Contains \ (e.g., C:\Users\x, \escaped)
Contains ' or " (e.g., "id", 'title')
Contains <> (e.g., a<b, a>b)
Contains whitespace \s (e.g., foo bar, class)
Contains = (e.g., a=b, onerror=alert(1))
Contains , (e.g., http://x/,)
Contains ( ) { } [ ] (e.g., foo(bar), leftover {}, [link])
Contains | (e.g., a|b)
Contains ; (e.g., foo;bar)
Contains :// (e.g., http://evil.test, https://example.com)
Control characters + DEL (charCode <= 0x1f || charCode === 0x7f)
NUL \0 (e.g., \0hidden)
SOH \x01 (e.g., a\x01b)
Tab \t (e.g., \tclass)
Newline \n (e.g., \nbreak)
Carriage return \r (e.g., \rsuffix)
DEL \x7f
C1 control characters (charCode >= 0x80 && charCode <= 0x9f)
Any character within these code points
Zero-width / bidirectional control characters / word joiners
ZWSP \u200b–\u200f (e.g., \u200bclass, class\u200b)
Line separator / paragraph separator / LRO / RLO / PDF \u2028–\u202e (e.g., \u202ertl)
Word joiner \u2060
Special Unicode characters
BOM \ufeff (e.g., \ufeffclass)
Replacement character \ufffd (e.g., \ufffdpath)
Surrogates (charCode >= 0xd800 && charCode <= 0xdfff, including emoji surrogate pairs)
Type and format checks in isValidAttrName (before regex)
name is null / undefined / not a string
name.trim() !== name (leading or trailing whitespace)
DOM createAttribute validation (after passing regex)
Attribute names that pass the above rules but still throw an InvalidCharacterError in the browser (e.g., xmlns:foo/bar)
Structural validation failures (non-regex, during full traversal)
Proxy ownKeys throws an exception → unable to enumerate keys → marked as kind: "attrs-inspection-failed", original object retained
Object is frozen/sealed and delete fails → reconstruct a prototype-free object
AST element node is not writable (tryReplaceAttrs returns false) → repaired: false, surviving illegal keys logged
Diagnostic log classification (display only, not for interception)
Pattern matching in classifyBadAttrReason():
/:/// or /^https?:/i → "URL/protocol string"
//\/ or /path\s*:/i or includes "{path" → "path fragment"
/[{}]/ → "curly brace residue"
/[@#$%^&*]/ → "special symbols"
/[\s"'<>=,]/ → "spaces/quotes/angle brackets/equals"
/[()[]|;]/ → "parentheses/vertical bar/semicolon"
/[^\x20-\x7E]/ → "non-ASCII"
!badAttr → "empty attribute name"
farnabaz commentedon Jul 30, 2026
I believe what you are looking for is bit specific and not a general use. It would be great plugin for Comark.
I'll update the PR to make sure attributes start with
a-zchars but other non-markdown streaming is too much for Comark core.This is also not possible imagine having
<div 3attr="value">, it is not possible to keep3attr="value"as text while it is an attributepony04311 commentedon Aug 10, 2026
ok thanks!