Skip to content

Commit

Permalink
Fixed CDATA RegExp to actually be a RegExp object instead of a string.
Browse files Browse the repository at this point in the history
  • Loading branch information
unclespike committed Dec 26, 2010
1 parent b066f1e commit bada29e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/XMLFragment.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class XMLFragment
throw new Error "Text nodes cannot have child nodes"
if not value?
throw new Error "Missing element text"
if not String(value).match("^" + @val.EntityValue + "$") and not String(value).match("^" + @val.CDATA + "$")
if not String(value).match("^" + @val.EntityValue + "$") and not String(value).match(@val.CDATA)
throw new Error "Invalid element text: " + value

child = new XMLFragment @, '', {}, value
Expand Down Expand Up @@ -182,7 +182,7 @@ XMLFragment::val.ExternalID =
'(?:' + 'SYSTEM' + XMLFragment::val.Space + XMLFragment::val.SystemLiteral + ')|'
'(?:' + 'PUBLIC' + XMLFragment::val.Space + XMLFragment::val.PubIDLateral +
XMLFragment::val.Space + XMLFragment::val.SystemLiteral
XMLFragment::val.CDATA = '<![CDATA[.*?]]>'
XMLFragment::val.CDATA = /^\<!\[CDATA\[.*?\]\]\>$/


module.exports = XMLFragment
4 changes: 2 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var xml = '<root>' +
'<xmlbuilder for="node-js" awesome="CoffeeScript">' +
'<repo type="git">git://github.com/oozcitak/xmlbuilder-js.git</repo>' +
'</xmlbuilder>' +
'<cdata><![CDATA[<test>this is a test</test>]]></cdata>' +
'<cdata><![CDATA[<test att="val">this is a test</test>]]></cdata>' +
'<test>complete</test>' +
'</root>';

Expand All @@ -20,7 +20,7 @@ builder.begin('root')
.up()
.up()
.ele('cdata')
.txt('<![CDATA[<test>this is a test</test>]]>')
.txt('<![CDATA[<test att="val">this is a test</test>]]>')
.up()
.up()
.ele('test')
Expand Down

0 comments on commit bada29e

Please sign in to comment.