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

Fails to preserve URLs as is #690

Closed
jaekyeom opened this issue Jun 4, 2018 · 6 comments
Closed

Fails to preserve URLs as is #690

jaekyeom opened this issue Jun 4, 2018 · 6 comments

Comments

@jaekyeom
Copy link

jaekyeom commented Jun 4, 2018

It fails to preserve URLs as is. For instance, try suspending and unsuspending http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=PREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0D%0A%0D%0ASELECT+%3Fperson+%3Fname+where+%7B%0D%0A+++%3Fperson+foaf%3Aname+%3Fname+.%0D%0A%7D+LIMIT+100&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=30000&debug=on&run=+Run+Query+.

Specifications:

  • Extension version: 7.0.85
  • Browser & version: Chrome 66.0.3359.181
  • Operating system & version: macOS Sierra 10.12.6
@fwextensions
Copy link
Contributor

That's probably because of the uri= in the URL. Calling gsUtils.getHashVariable("uri", "blah#uri=http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=PREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0D%0A%0D%0ASELECT+%3Fperson+%3Fname+where+%7B%0D%0A+++%3Fperson+foaf%3Aname+%3Fname+.%0D%0A%7D+LIMIT+100&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=30000&debug=on&run=+Run+Query+") returns "http://dbpedia.org/sparql?default-graph-". It doesn't look like the code handles a URL with a uri= substring already in it.

@fwextensions
Copy link
Contributor

Interestingly, my QuicKey extension unsuspends that page to the correct URL. It assumes everything from the uri= to the end of the string is the unsuspended URL, which might be a bad assumption if TGS ever changes the hash format.

@jaekyeom
Copy link
Author

jaekyeom commented Jun 5, 2018

Let's make the great suspender great again...

@fwextensions Thanks for looking into this issue.
So, I guess it is just a matter of splitting hashStr into only two pieces based on the first occurrence of uri= here.

@fwextensions
Copy link
Contributor

fwextensions commented Jun 5, 2018

Right. Looks like changing that line to this would fix it:

valuesByKey.uri = hashStr.split('uri=').slice(1).join("");

That joins the split pieces back together, in case the uri gets split into multiple pieces. I changed it in an alpha build and it does seem to work.

But just slicing at the index of "uri=" might be a little more straightforward. Or matching with a regex, since one's used to pull out the # anyway, something like this:

var match = urlStr.match(/^[^#]+#(.*?)&?uri=(.+)$/);

if (!match) {
    return false;
}

hashStr = match[1];
valuesByKey.uri = match[2];

And using a new URLSearchParams() to parse the key/values would probably be a little safer than just splitting on &.

Anyway, it looks like assuming uri is the very last parameter is a safe assumption since it has to be, given that it's not URI-encoded. Otherwise, any params in the URI would get mixed in with TGS's.

@deanoemcke
Copy link
Collaborator

Thanks for this.
I'll try to fix this asap.

@deanoemcke
Copy link
Collaborator

I have pushed a fix for this (40ce23f)

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

No branches or pull requests

3 participants