[Pkg-javascript-commits] [ltx] 213/469: sax_easysax: unescape attributes + test

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:03:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository ltx.

commit 433600515bbed9b1c4f2377981465e37729ffd3c
Author: Astro <astro at spaceboyz.net>
Date:   Mon Mar 19 18:12:46 2012 +0100

    sax_easysax: unescape attributes + test
---
 lib/sax_easysax.js | 7 ++++++-
 test/parse-test.js | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/sax_easysax.js b/lib/sax_easysax.js
index b28cc16..510669e 100644
--- a/lib/sax_easysax.js
+++ b/lib/sax_easysax.js
@@ -7,7 +7,12 @@ var SaxEasysax = module.exports = function SaxEasysax() {
     this.parser = new Easysax();
     var that = this;
     this.parser.on('startNode', function(name, attr, uq, str, tagend) {
-        that.emit('startElement', name, attr());
+	attr = attr();
+	for(var k in attr)
+	    if (attr.hasOwnProperty(k)) {
+		attr[k] = uq(attr[k]);
+	    }
+        that.emit('startElement', name, attr);
     });
     this.parser.on('endNode', function(name, uq, str, tagstart) {
         that.emit('endElement', name);
diff --git a/test/parse-test.js b/test/parse-test.js
index e06f3e6..86fd4dd 100644
--- a/test/parse-test.js
+++ b/test/parse-test.js
@@ -21,6 +21,10 @@ ltx.availableSaxParsers.forEach(function(saxParser) {
                 var el = parse("<body><>&"'</body>");
                 assert.equal("<>&\"'", el.getText());
             },
+            'attribute with entities': function() {
+		var el = parse("<body title='<>&"''/>");
+		assert.equal("<>&\"'", el.attrs.title);
+            },
             'erroneous document raises error': function() {
                 assert.throws(function() {
                     parse('<root></toor>');

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git



More information about the Pkg-javascript-commits mailing list