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

Comments

Projects
None yet
2 participants
@ilkkao

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

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Aug 29, 2014

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().

Member

rodneyrehm commented Aug 29, 2014

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

This comment has been minimized.

Show comment
Hide comment
@ilkkao

ilkkao 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 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 Aug 29, 2014

@ilkkao ilkkao reopened this Aug 29, 2014

@ilkkao

This comment has been minimized.

Show comment
Hide comment
@ilkkao

ilkkao 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.

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

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Aug 29, 2014

Member

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

Member

rodneyrehm commented Aug 29, 2014

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

@rodneyrehm rodneyrehm closed this Aug 29, 2014

@ilkkao

This comment has been minimized.

Show comment
Hide comment
@ilkkao

ilkkao Aug 29, 2014

Thanks. Appreciated!

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