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

URI.readble throws an exeption #163

Closed
ilkkao opened this issue Aug 29, 2014 · 5 comments
Closed

URI.readble throws an exeption #163

ilkkao opened this issue Aug 29, 2014 · 5 comments

Comments

@ilkkao
Copy link

ilkkao commented Aug 29, 2014

var a = new URI("http://varuste.net/Adventure+Partners+K%F6ysitoiminnan+perustaitoja+geok%E4tk%F6ilij%F6ille?_tu=59486")
a.readable()

Throws an exception: Uncaught URIError: URI malformed. The problem is at least %F6, it's supposed to encode finnish letter ö.

Browser is Google Chrome 38 beta on Mac. There wasn't mention in the docs that readble can throw so I decided to open an issue.

@rodneyrehm
Copy link
Member

yes, because you have a malformed URI:

decodeURIComponent("Adventure+Partners+K%F6ysitoiminnan+perustaitoja+geok%E4tk%F6ilij%F6ille");

It is .decodePathSegment() that is calling decodeURIComponent without handling a possible exception like it's done in .decodeQuery().

@ilkkao
Copy link
Author

ilkkao commented Aug 29, 2014

My example is actually inside var URI.withinString('xyz', function(uli) {}) callback. Now I checked the documentation again and I see that there's ``var uri = new URI(url);` but the readble() needs to be called on url not uri.

I'll fix my code.

@ilkkao ilkkao closed this as completed Aug 29, 2014
@ilkkao ilkkao reopened this Aug 29, 2014
@ilkkao
Copy link
Author

ilkkao commented Aug 29, 2014

Actually there's an error in the docs

var result = URI.withinString(source, function(url) {
  var uri = new URI(url);
  uri.normalize();
  return "<a href="" + escapeHtml(uri) + "">" 
    + escapeHtml(url.readable()) + "</a>";
});

Url is a string and doesn't have readable(). Seems that the only way to handle any user generated input is to catch the exception in the callback.

@rodneyrehm
Copy link
Member

both problems are fixed in master and will be released with the next version.

@ilkkao
Copy link
Author

ilkkao commented Aug 29, 2014

Thanks. Appreciated!

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

No branches or pull requests

2 participants