Changeset 31231 for trunk/WebCore/dom/Document.cpp
- Timestamp:
- 03/22/08 02:50:54 (8 months ago)
- Files:
-
- 1 modified
-
trunk/WebCore/dom/Document.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/dom/Document.cpp
r31230 r31231 718 718 } 719 719 720 static bool hasNamespaceError(const QualifiedName& qName)721 { 722 static const AtomicString xmlnsNamespaceURI = "http://www.w3.org/2000/xmlns/";723 static const AtomicString xmlns = "xmlns";724 static const AtomicString xml = "xml";720 bool Document::hasPrefixNamespaceMismatch(const QualifiedName& qName) 721 { 722 static const AtomicString xmlnsNamespaceURI("http://www.w3.org/2000/xmlns/"); 723 static const AtomicString xmlns("xmlns"); 724 static const AtomicString xml("xml"); 725 725 726 726 // These checks are from DOM Core Level 2, createElementNS 727 727 // http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-DocCrElNS 728 if (qName.prefix() == emptyAtom) // createElementNS(null, ":div")729 return true;730 if (qName.localName().isEmpty()) // createElementNS(null, ""), createElementNS(null, null), createElementNS()731 return true;732 728 if (!qName.prefix().isEmpty() && qName.namespaceURI().isNull()) // createElementNS(null, "html:div") 733 729 return true; … … 778 774 { 779 775 String prefix, localName; 780 if (!parseQualifiedName(qualifiedName, prefix, localName)) { 781 ec = INVALID_CHARACTER_ERR; 776 if (!parseQualifiedName(qualifiedName, prefix, localName, ec)) 782 777 return 0; 783 }784 778 785 779 QualifiedName qName(prefix, localName, namespaceURI); 786 if (has NamespaceError(qName)) {780 if (hasPrefixNamespaceMismatch(qName)) { 787 781 ec = NAMESPACE_ERR; 788 782 return 0; … … 2820 2814 } 2821 2815 2822 bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, String& localName )2816 bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode& ec) 2823 2817 { 2824 2818 unsigned length = qualifiedName.length(); 2825 2819 2826 if (length == 0) 2820 if (length == 0) { 2821 ec = INVALID_CHARACTER_ERR; 2827 2822 return false; 2823 } 2828 2824 2829 2825 bool nameStart = true; … … 2836 2832 U16_NEXT(s, i, length, c) 2837 2833 if (c == ':') { 2838 if (sawColon) 2834 if (sawColon) { 2835 ec = NAMESPACE_ERR; 2839 2836 return false; // multiple colons: not allowed 2837 } 2840 2838 nameStart = true; 2841 2839 sawColon = true; 2842 2840 colonPos = i - 1; 2843 2841 } else if (nameStart) { 2844 if (!isValidNameStart(c)) 2842 if (!isValidNameStart(c)) { 2843 ec = INVALID_CHARACTER_ERR; 2845 2844 return false; 2845 } 2846 2846 nameStart = false; 2847 2847 } else { 2848 if (!isValidNamePart(c)) 2848 if (!isValidNamePart(c)) { 2849 ec = INVALID_CHARACTER_ERR; 2849 2850 return false; 2851 } 2850 2852 } 2851 2853 } … … 2856 2858 } else { 2857 2859 prefix = qualifiedName.substring(0, colonPos); 2860 if (prefix.isEmpty()) { 2861 ec = NAMESPACE_ERR; 2862 return false; 2863 } 2858 2864 localName = qualifiedName.substring(colonPos + 1); 2865 } 2866 2867 if (localName.isEmpty()) { 2868 ec = NAMESPACE_ERR; 2869 return false; 2859 2870 } 2860 2871 … … 3528 3539 { 3529 3540 String prefix, localName; 3530 if (!parseQualifiedName(qualifiedName, prefix, localName)) { 3531 ec = INVALID_CHARACTER_ERR; 3541 if (!parseQualifiedName(qualifiedName, prefix, localName, ec)) 3532 3542 return 0; 3533 }3534 3543 3535 3544 QualifiedName qName(prefix, localName, namespaceURI); 3536 if (has NamespaceError(qName)) {3545 if (hasPrefixNamespaceMismatch(qName)) { 3537 3546 ec = NAMESPACE_ERR; 3538 3547 return 0;