Opened 13 years ago
Closed 13 years ago
#6039 closed defect (fixed)
DomParser: need support for element attributes defined using single quotes
Reported by: | guest | Owned by: | Tom Trenka |
---|---|---|---|
Priority: | high | Milestone: | 1.2 |
Component: | Dojox | Version: | 1.0 |
Keywords: | dojox xml DomParser Atom | Cc: | [email protected]… |
Blocked By: | Blocking: |
Description (last modified by )
I'm using 1.0.2's dojox.xml.DomParser? to process Atom feeds and came across one that used single quotes today, and:
DomParser.js:33 var reAttr=/([^=]*)="([^"]*)"/g;
failed to match any attributes. The solution I use is:
// fix part 1: attr[3] and [4] will be matched double or single contents resp. DomParser.js:33 var reAttr=/([^=]*)=("([^"]*)"|'([^']*)')/g; ... DomParser.js: around line 300 ... // parse the attribute string. var attr; while((attr=reAttr.exec(res[2]))!=null){ if(attr.length>0){ // fix part 2: roll up single attr[4] or double attr[3] ---> attr[2]= attr[3] || attr[4]; var name=attr[1].replace(trim,""); var val=attr[2].replace(normalize," ") ...
Attachments (1)
Change History (9)
comment:1 Changed 13 years ago by
Milestone: | → 1.2 |
---|---|
Owner: | changed from Adam Peller to Tom Trenka |
comment:2 Changed 13 years ago by
Changed 13 years ago by
Attachment: | test_DomParserAttributeParsing.html added |
---|
if it helps, here's a test case -tim
comment:3 Changed 13 years ago by
I actually tried using the back reference approach, but it won't work on mixed attribute content like:
<replace what='"' with="'" />
;) -Tim
comment:4 Changed 13 years ago by
Description: | modified (diff) |
---|---|
Summary: | dojox.xml.DomParser -- support for element attributes defined using single quotes → DomParser: need support for element attributes defined using single quotes |
comment:5 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 Changed 13 years ago by
comment:7 Changed 13 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
[14430] introduces an issue with parsing empty attributes...
console.log(dojox.xml.DomParser.parse('<z><p a="" >foo</p></z>'));
The code (line 312) is doing (""||undefined).replace(...)
and its failing as "" evaluates to false so the expression result is undefined.
comment:8 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Note: See
TracTickets for help on using
tickets.
You're correct: XML should support either single or double-quoted attributes. My bad.
When the dust settles around the 1.1 release, I'll replace that line with this:
var reAttr=/([=]*)=(['"])(['"]*)2/g
It's not your expression (yours is a little more inefficient but will work) but it will work.