garycourt / uri-js

An RFC 3986 compliant, scheme extendable URI parsing/validating/normalizing/resolving library for JavaScript
Other
305 stars 69 forks source link

resolve() #1

Closed PAEz closed 12 years ago

PAEz commented 12 years ago

If a '/n' is in the resolved path then it seems to go into an infinite loop and gobbles up memory until it crashs....

URI.resolve('//www.g.com/','/adf\ngf')

or

URI.resolve('//www.g.com/error\n/bleh/bleh','..')

I know this wouldnt come up that much but Im using it in a web crawler for Chrome and its come up a couple of times. Im dealing with it by cleaning the url with some regex ( .replace(/(\r\n|\n|\r|\t)/gm, "") ) and then checking both urls parsed without errors before resolving. But there might be more special characters that would cause this and thought you should know.

And while Im here... Thanks for sharing your code. Ive tried every url parser I could get my hands on and yours turned out to be the best (especially with your graceful error handling), so well done and thank you.

PAEz

Had a look and its in removeDotSegments that the loop occurs, unfortunately I cant do regex stuff so Im no help.

garycourt commented 12 years ago

Thanks for finding and reporting this. This problem would only have occured with newline characters. I have pushed a fix to master.

Also, thanks for the compliment!

garycourt commented 12 years ago

Discovered \n characters are not being encoded correctly. New fix pushed to master.