Commit d472e33
committed
Allow more characters in element/attribute names and prefixes
https://bugs.webkit.org/show_bug.cgi?id=241419
Reviewed by NOBODY (OOPS!).
Implement relaxed name-validation rules per whatwg/dom#1079, whatwg/html#7991,
and whatwg/html#11453. This aligns DOM API name behavior with HTML parser behavior —
which has always allowed a wider range of characters in element and attribute names.
New validation functions in NameValidation.h/cpp:
- isValidElementName(): For createElement — allows [A-Za-z] start followed by
any char except null/whitespace/>//, or [:_>=0x80] start with restricted continuation
- isValidAttributeName(): For setAttribute/toggleAttribute/createAttribute —
no null, whitespace, /, >, or =
- isValidNamespacePrefix(): For *NS methods — no null, whitespace, /, or >
- isValidDoctypeName(): For createDocumentType — no null, whitespace, or >
- isValidXMLName(): Preserves old XML Name production for createProcessingInstruction
* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocumentType):
* Source/WebCore/dom/Document.cpp:
(WebCore::createHTMLElementWithNameValidation):
(WebCore::Document::createElementForBindings):
(WebCore::Document::createProcessingInstruction):
(WebCore::Document::createElementNS):
(WebCore::Document::createAttribute):
(WebCore::Document::createAttributeNS):
(WebCore::isValidNameStart): Deleted.
(WebCore::isValidNamePart): Deleted.
(WebCore::isValidHTMLElementName):
(WebCore::Document::hasValidNamespaceForElements): Deleted.
(WebCore::Document::hasValidNamespaceForAttributes): Deleted.
(WebCore::isValidNameNonASCII): Deleted.
(WebCore::isValidNameASCII): Deleted.
(WebCore::isValidNameASCIIWithoutColon): Deleted.
(WebCore::Document::isValidName): Deleted.
(WebCore::Document::parseQualifiedName): Deleted.
* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::toggleAttribute):
(WebCore::Element::setAttribute):
(WebCore::Element::setAttributeNS):
(WebCore::Element::parseAttributeName):
* Source/WebCore/dom/Element.h:
* Source/WebCore/dom/NameValidation.cpp: Added.
(WebCore::NameValidation::isInvalidAttributeNameCharacter):
(WebCore::NameValidation::isInvalidElementNameCharacterAfterAlphaStart):
(WebCore::NameValidation::isValidElementNameContinuationCharacter):
(WebCore::NameValidation::isInvalidNamespacePrefixCharacter):
(WebCore::NameValidation::isInvalidDoctypeNameCharacter):
(WebCore::NameValidation::isValidElementName):
(WebCore::NameValidation::isValidAttributeName):
(WebCore::NameValidation::isValidNamespacePrefix):
(WebCore::NameValidation::isValidDoctypeName):
(WebCore::NameValidation::isValidASCIIXMLName):
(WebCore::NameValidation::isValidXMLNameStart):
(WebCore::NameValidation::isValidXMLNamePart):
(WebCore::NameValidation::isValidXMLName):
(WebCore::NameValidation::parseQualifiedNameToPair):
(WebCore::NameValidation::parseQualifiedElementName):
(WebCore::NameValidation::parseQualifiedAttributeName):
(WebCore::NameValidation::hasValidNamespaceForElements):
(WebCore::NameValidation::hasValidNamespaceForAttributes):
* Source/WebCore/dom/NameValidation.h: Added.
* Source/WebCore/dom/Node.cpp:
(WebCore::Node::checkSetPrefix):
* Source/WebCore/dom/ProcessingInstruction.cpp:
* Source/WebCore/editing/EditorCommand.cpp:
(WebCore::executeFormatBlock):
* Source/WebCore/svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::constructAttributeName const):
* Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::handleNamespaceAttributes):
(WebCore::handleElementAttributes):1 parent 0cec9ab commit d472e33
File tree
15 files changed
+390
-243
lines changed- Source/WebCore
- WebCore.xcodeproj
- dom
- editing
- svg/animation
- xml/parser
15 files changed
+390
-243
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1341 | 1341 | | |
1342 | 1342 | | |
1343 | 1343 | | |
| 1344 | + | |
1344 | 1345 | | |
1345 | 1346 | | |
1346 | 1347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1321 | 1321 | | |
1322 | 1322 | | |
1323 | 1323 | | |
| 1324 | + | |
1324 | 1325 | | |
1325 | 1326 | | |
1326 | 1327 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4451 | 4451 | | |
4452 | 4452 | | |
4453 | 4453 | | |
| 4454 | + | |
4454 | 4455 | | |
4455 | 4456 | | |
4456 | 4457 | | |
| |||
17383 | 17384 | | |
17384 | 17385 | | |
17385 | 17386 | | |
| 17387 | + | |
| 17388 | + | |
17386 | 17389 | | |
17387 | 17390 | | |
17388 | 17391 | | |
| |||
41688 | 41691 | | |
41689 | 41692 | | |
41690 | 41693 | | |
| 41694 | + | |
| 41695 | + | |
41691 | 41696 | | |
41692 | 41697 | | |
41693 | 41698 | | |
| |||
46214 | 46219 | | |
46215 | 46220 | | |
46216 | 46221 | | |
| 46222 | + | |
46217 | 46223 | | |
46218 | 46224 | | |
46219 | 46225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | | - | |
82 | | - | |
83 | | - | |
| 82 | + | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
| |||
521 | 522 | | |
522 | 523 | | |
523 | 524 | | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | 525 | | |
543 | 526 | | |
544 | 527 | | |
| |||
1550 | 1533 | | |
1551 | 1534 | | |
1552 | 1535 | | |
1553 | | - | |
1554 | | - | |
1555 | | - | |
1556 | | - | |
1557 | | - | |
1558 | | - | |
1559 | | - | |
1560 | | - | |
1561 | | - | |
1562 | | - | |
1563 | 1536 | | |
1564 | 1537 | | |
1565 | 1538 | | |
| |||
1575 | 1548 | | |
1576 | 1549 | | |
1577 | 1550 | | |
1578 | | - | |
| 1551 | + | |
1579 | 1552 | | |
1580 | 1553 | | |
1581 | 1554 | | |
| |||
1603 | 1576 | | |
1604 | 1577 | | |
1605 | 1578 | | |
1606 | | - | |
| 1579 | + | |
1607 | 1580 | | |
1608 | 1581 | | |
1609 | 1582 | | |
| |||
1654 | 1627 | | |
1655 | 1628 | | |
1656 | 1629 | | |
1657 | | - | |
1658 | | - | |
| 1630 | + | |
| 1631 | + | |
1659 | 1632 | | |
1660 | 1633 | | |
1661 | 1634 | | |
| |||
1748 | 1721 | | |
1749 | 1722 | | |
1750 | 1723 | | |
1751 | | - | |
1752 | | - | |
1753 | | - | |
1754 | | - | |
1755 | | - | |
1756 | | - | |
1757 | | - | |
1758 | | - | |
1759 | | - | |
1760 | | - | |
1761 | | - | |
1762 | | - | |
1763 | | - | |
1764 | | - | |
1765 | | - | |
1766 | | - | |
1767 | | - | |
1768 | | - | |
1769 | | - | |
1770 | | - | |
1771 | | - | |
1772 | | - | |
1773 | 1724 | | |
1774 | 1725 | | |
1775 | 1726 | | |
| |||
2039 | 1990 | | |
2040 | 1991 | | |
2041 | 1992 | | |
2042 | | - | |
| 1993 | + | |
2043 | 1994 | | |
2044 | 1995 | | |
2045 | 1996 | | |
2046 | | - | |
| 1997 | + | |
2047 | 1998 | | |
2048 | 1999 | | |
2049 | 2000 | | |
| |||
7473 | 7424 | | |
7474 | 7425 | | |
7475 | 7426 | | |
7476 | | - | |
7477 | | - | |
7478 | | - | |
7479 | | - | |
7480 | | - | |
7481 | | - | |
7482 | | - | |
7483 | | - | |
7484 | | - | |
7485 | | - | |
7486 | | - | |
7487 | | - | |
7488 | | - | |
7489 | | - | |
7490 | | - | |
7491 | | - | |
7492 | | - | |
7493 | | - | |
7494 | | - | |
7495 | | - | |
7496 | | - | |
7497 | | - | |
7498 | | - | |
7499 | | - | |
7500 | | - | |
7501 | | - | |
7502 | | - | |
7503 | | - | |
7504 | | - | |
7505 | | - | |
7506 | | - | |
7507 | | - | |
7508 | | - | |
7509 | | - | |
7510 | | - | |
7511 | | - | |
7512 | | - | |
7513 | | - | |
7514 | | - | |
7515 | | - | |
7516 | | - | |
7517 | | - | |
7518 | | - | |
7519 | | - | |
7520 | | - | |
7521 | | - | |
7522 | | - | |
7523 | | - | |
7524 | | - | |
7525 | | - | |
7526 | | - | |
7527 | | - | |
7528 | | - | |
7529 | | - | |
7530 | | - | |
7531 | | - | |
7532 | | - | |
7533 | | - | |
7534 | | - | |
7535 | | - | |
7536 | | - | |
7537 | | - | |
7538 | | - | |
7539 | | - | |
7540 | | - | |
7541 | | - | |
7542 | | - | |
7543 | | - | |
7544 | | - | |
7545 | | - | |
7546 | | - | |
7547 | | - | |
7548 | | - | |
7549 | | - | |
7550 | | - | |
7551 | | - | |
7552 | | - | |
7553 | | - | |
7554 | | - | |
7555 | | - | |
7556 | | - | |
7557 | | - | |
7558 | | - | |
7559 | | - | |
7560 | | - | |
7561 | | - | |
7562 | | - | |
7563 | | - | |
7564 | | - | |
7565 | | - | |
7566 | | - | |
7567 | | - | |
7568 | | - | |
7569 | | - | |
7570 | | - | |
7571 | | - | |
7572 | | - | |
7573 | | - | |
7574 | | - | |
7575 | | - | |
7576 | | - | |
7577 | | - | |
7578 | | - | |
7579 | | - | |
7580 | | - | |
7581 | | - | |
7582 | | - | |
7583 | | - | |
7584 | | - | |
7585 | | - | |
7586 | | - | |
7587 | | - | |
7588 | | - | |
7589 | | - | |
7590 | | - | |
7591 | | - | |
7592 | | - | |
7593 | | - | |
7594 | | - | |
7595 | | - | |
7596 | | - | |
7597 | | - | |
7598 | | - | |
7599 | | - | |
7600 | | - | |
7601 | | - | |
7602 | | - | |
7603 | | - | |
7604 | | - | |
7605 | | - | |
7606 | | - | |
7607 | | - | |
7608 | 7427 | | |
7609 | 7428 | | |
7610 | 7429 | | |
| |||
8170 | 7989 | | |
8171 | 7990 | | |
8172 | 7991 | | |
8173 | | - | |
8174 | | - | |
| 7992 | + | |
| 7993 | + | |
8175 | 7994 | | |
8176 | 7995 | | |
8177 | 7996 | | |
8178 | 7997 | | |
8179 | 7998 | | |
8180 | | - | |
| 7999 | + | |
8181 | 8000 | | |
8182 | 8001 | | |
8183 | 8002 | | |
8184 | | - | |
| 8003 | + | |
8185 | 8004 | | |
8186 | 8005 | | |
8187 | 8006 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1250 | 1250 | | |
1251 | 1251 | | |
1252 | 1252 | | |
1253 | | - | |
1254 | | - | |
1255 | | - | |
1256 | | - | |
1257 | | - | |
1258 | | - | |
1259 | | - | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
1263 | | - | |
1264 | | - | |
1265 | | - | |
1266 | 1253 | | |
1267 | 1254 | | |
1268 | 1255 | | |
| |||
0 commit comments