]> git.eshelyaron.com Git - emacs.git/commitdiff
xml: Properly handle symbol-qnames for attribute parsing
authorDavid Engster <deng@randomsample.de>
Mon, 17 Apr 2017 14:52:08 +0000 (16:52 +0200)
committerDavid Engster <deng@randomsample.de>
Mon, 17 Apr 2017 15:17:00 +0000 (17:17 +0200)
* lisp/xml.el (xml-parse-attlist): Do not strip 'symbol-qnames from
  xml-ns argument (reverts aea67018) (Bug#26533).
  (xml-maybe-do-ns): Properly handle default namespace by not
  interning new symbol when 'special' flag is set.

* tests/lisp/xml-tests.el (xml-parse-test--namespace-attribute-qnames)
  (xml-parse-namespace-attribute-qnames): Add test for Bug#26533.

lisp/xml.el
test/lisp/xml-tests.el

index be2ac96f264f321e4cf003f889f0cdbf831eb212..88dc70bc413661ac9cb741cedd8afbe097a59861 100644 (file)
@@ -437,6 +437,7 @@ in the XML-NS argument."
                                  (if symbol-qnames (cdr xml-ns) xml-ns)))
                      "")))
        (if (and symbol-qnames
+                 (not special)
                 (not (string= prefix "xmlns")))
            (intern (concat ns lname))
          (cons ns (if special "" lname))))
@@ -646,10 +647,8 @@ surpassed `xml-entity-expansion-limit'"))))
 (defun xml-parse-attlist (&optional xml-ns)
   "Return the attribute-list after point.
 Leave point at the first non-blank character after the tag."
-  (let* ((attlist ())
-        (symbol-qnames (eq (car-safe xml-ns) 'symbol-qnames))
-        (xml-ns (if symbol-qnames (cdr xml-ns) xml-ns))
-        end-pos name)
+  (let ((attlist ())
+        end-pos name)
     (skip-syntax-forward " ")
     (while (looking-at (eval-when-compile
                         (concat "\\(" xml-name-re "\\)\\s-*=\\s-*")))
index d0da2094db70cccdcfa351ddd8410c0b0fd5264f..16945b0f92d83028a27c3bc4696350beb52ce2f6 100644 (file)
@@ -149,6 +149,21 @@ Parser is called with and without 'symbol-qnames argument.")
     (should (equal (cdr xml-parse-test--default-namespace-qnames)
                    (xml-parse-region nil nil nil nil 'symbol-qnames)))))
 
+;; Test bug #26533 (proper expansion in prefixed attributes with 'symbol-qnames)
+(defvar xml-parse-test--namespace-attribute-qnames
+  (cons "<something xmlns:a=\"myns:\"><whatever a:b='c'></whatever></something>"
+        '((something
+           ((("http://www.w3.org/2000/xmlns/" . "a")
+             . "myns:"))
+           (whatever
+            ((myns:b . "c")))))))
+
+(ert-deftest xml-parse-namespace-attribute-qnames ()
+  (with-temp-buffer
+    (insert (car xml-parse-test--namespace-attribute-qnames))
+    (should (equal (cdr xml-parse-test--namespace-attribute-qnames)
+                   (xml-parse-region nil nil nil nil 'symbol-qnames)))))
+
 ;; Local Variables:
 ;; no-byte-compile: t
 ;; End: