Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nori explodes when there is a trailing apostrophe #15

Closed
iblue opened this issue Apr 13, 2012 · 1 comment
Closed

Nori explodes when there is a trailing apostrophe #15

iblue opened this issue Apr 13, 2012 · 1 comment

Comments

@iblue
Copy link

iblue commented Apr 13, 2012

Consider the following SOAP answer from our payment backend:

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ns1:authorizeResponse xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"><ipaymentReturn><status xmlns="">SUCCESS</status><successDetails xmlns=""><retTransDate xmlns="">13.04.12</retTransDate><retTransTime xmlns="">18:21:59</retTransTime><retTrxNumber xmlns="">1-987654321</retTrxNumber><retAuthCode xmlns=""></retAuthCode><retStorageId xmlns="">12345678</retStorageId></successDetails><paymentMethod xmlns="">VisaCard</paymentMethod><trxRemoteIpCountry xmlns="">DE</trxRemoteIpCountry></ipaymentReturn></ns1:authorizeResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

Now if you add an apostrophe (') to this answer, Nori parses this as {:envelope=>2013-04-12 01:00:00 +0200}. Trailing apostrophe happens often, e.g. if you mock SOAP-Answers with '...lots of ugly xml', insert some variables, find out that its best to encapsulate strings with %{...lots of ugly xml...} and just forget to remove the ' at the end. And you spend hours on debugging.

@tjarratt
Copy link
Contributor

Closing as won't fix. I'm not entirely convinced that this is something that Nori should fix, since the input is invalid.

Regardless, this seems to work better with modern versions of Nori. Feel free to re-open @iblue if you disagree. There's certainly room for Nori to improve its error handling, and I'd be more than happy to merge pull requests that improve any aspect of it.

± bundle exec irb
2.1.2 :001 > require 'nori'
 => true 
2.1.2 :002 > Nori.new.parse("<xml></xml>")
 => {"xml"=>nil} 
2.1.2 :003 > Nori.new.parse("<xml>blah</xml>")
 => {"xml"=>"blah"} 
2.1.2 :004 > Nori.new.parse("<xml>blah</xml>'")
 => {"xml"=>"blah"} 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants