From ed59843b7fa456e0614c2c63e1479458642671ea Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 4 Jun 2019 21:08:26 -0400 Subject: [PATCH] Fix nxml syntax propertizing assertion failure (Bug#36092) * lisp/textmodes/sgml-mode.el (sgml-syntax-propertize): Use the syntax-ppss-table syntax-table. * test/lisp/nxml/nxml-mode-tests.el (nxml-mode->-after-quote): New test. --- lisp/textmodes/sgml-mode.el | 17 +++++++++-------- test/lisp/nxml/nxml-mode-tests.el | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 0c5d5e56a6..09211e1661 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -399,14 +399,15 @@ (eval-and-compile (defun sgml-syntax-propertize (start end) "Syntactic keywords for `sgml-mode'." - (setq sgml--syntax-propertize-ppss (cons start (syntax-ppss start))) - (cl-assert (>= (cadr sgml--syntax-propertize-ppss) 0)) - (sgml-syntax-propertize-inside end) - (funcall - (syntax-propertize-rules sgml-syntax-propertize-rules) - start end) - ;; Catch any '>' after the last quote. - (sgml--syntax-propertize-ppss end)) + (with-syntax-table syntax-ppss-table + (setq sgml--syntax-propertize-ppss (cons start (syntax-ppss start))) + (cl-assert (>= (cadr sgml--syntax-propertize-ppss) 0)) + (sgml-syntax-propertize-inside end) + (funcall + (syntax-propertize-rules sgml-syntax-propertize-rules) + start end) + ;; Catch any '>' after the last quote. + (sgml--syntax-propertize-ppss end))) (defun sgml-syntax-propertize-inside (end) (let ((ppss (syntax-ppss))) diff --git a/test/lisp/nxml/nxml-mode-tests.el b/test/lisp/nxml/nxml-mode-tests.el index 70816bb9de..53416b4280 100644 --- a/test/lisp/nxml/nxml-mode-tests.el +++ b/test/lisp/nxml/nxml-mode-tests.el @@ -99,5 +99,20 @@ (ert-deftest nxml-mode-prolog-comment () (should (nth 4 (syntax-ppss))) (search-forward "comment3"))) +(ert-deftest nxml-mode->-after-quote () + "Reduction from Bug#36092." + (with-temp-buffer + (insert "\n" + (make-string 1794 ?a) "\n" + "'>" + (make-string 196 ?a) "\n" + "") + (nxml-mode) + (syntax-propertize 2001) + (syntax-propertize (point-max)) ; Triggered an assert failure. + ;; Check that last tag is parsed as a tag. + (should (= 1 (- (car (syntax-ppss (1- (point-max)))) + (car (syntax-ppss (point-max)))))))) + (provide 'nxml-mode-tests) ;;; nxml-mode-tests.el ends here -- 2.11.0