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

url!s are cut at curly braces when reading #1046

Closed
IngoHohmann opened this issue Feb 5, 2020 · 4 comments
Closed

url!s are cut at curly braces when reading #1046

IngoHohmann opened this issue Feb 5, 2020 · 4 comments

Comments

@IngoHohmann
Copy link

>> to text! read to url! {https://httpbin.org/anything?a={"x":"y"}} 
== {{
  "args": {
    "a": ""
  }, 
  "data": "", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Charset": "utf-8", 
    "Host": "httpbin.org", 
    "User-Agent": "REBOL", 
    "X-Amzn-Trace-Id": "Root=1-5e3b13d1-1b00ba3c41d343bcd6626578"
  }, 
  "json": null, 
  "method": "GET", 
  "origin": "134.101.146.93", 
  "url": "https://httpbin.org/anything?a="
}
}

It works, if it is run through ENHEX.

>> to text! read to url! enhex {https://httpbin.org/anything?a={"x":"y"}}
== {{
  "args": {
    "a": "{\"x\":\"y\"}"
  }, 
  "data": "", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Charset": "utf-8", 
    "Host": "httpbin.org", 
    "User-Agent": "REBOL", 
    "X-Amzn-Trace-Id": "Root=1-5e3b13ea-462eb19c983b8d68a906994c"
  }, 
  "json": null, 
  "method": "GET", 
  "origin": "134.101.146.93", 
  "url": "https://httpbin.org/anything?a={\"x\":\"y\"}"
}
}

According to https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding braces do not need to be encoded.

@hostilefork
Copy link
Member

This is a further argument for the infamous "Plan -4 from Outer Space", which says that a{b} would not be legal (or more accurately, reserved for alternative use as opposed to a synonym for a b).

It seems the lack of an encoding requirement makes this one unambiguous, and a bug. There's still a lot of gray area for the characters that can/may be percent encoded...when they are encoded...and what that means. I need to get my head around it:

[a <b> http://foo{bar}]   ; so, this should work...
[a <b> http://foo(bar)]  ; this *can* work...
[a <b> http://foo)bar]  ; this *might* work if `)b` is illegal 
[a <b> http://foo) bar]  ; this *can't* work as `(http://foo)` is a GROUP!

That said... this issue is cross-cutting and present in R3-Alpha, hence please migrate it to rebol-issues. It would be ideal if you can do a bit of research there to find related bugs or theory posts on this. I want a coherent philosophy but we live in a messy world, and given how many things I have to hold in my head I can't remember even what I've figured out without a comprehensive motivation + spec.

r3-alpha>> to string! read to url! {http://httpbin.org/anything?a={"x":"y"}}   
== {{
  "args": {
    "a": ""
  }, 
  "data": "", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Charset": "utf-8", 
    "Host": "httpbin.org", 
    "User-Agent": "REBOL", 
    "X-Amzn-Trace-Id": "Root=1-5e3b1de9-013ef240bf4a8780df8b7c80"
  }, 
  "json": null, 
  "method": "GET", 
  "origin": "99.68.242.119", 
  "url": "http://httpbin.org/anything?a="
}
}

@IngoHohmann
Copy link
Author

I don't know how to move to rebol-issues, but added my comment to metaeducation/rebol-issues#2381 and marked some related issues there.

@hostilefork
Copy link
Member

There's actually the ability to transfer issues within an organization or account's repository now in GitHub, but adding it there is probably best.

Because I believe in Plan -4, I think we can go ahead and start moving that direction. "Redbol" can use an advanced form of loading which tries to LOAD and if it fails on a violation of Plan -4 then it can massage the remaining portion to put in enough spaces to try and retry the load.

I can probably hack this particularly request in shortly (once I take care of the things I'm trying to take care of), but like I say, we need a bigger picture "philosophy of URL! and encoding" story all written down in one place. I'm pretty sure I've had some realizations here and there, but with the number of things I do it's hard to keep them all on the top of my head.

@hostilefork
Copy link
Member

All right, you got it:

3139b41

We still need that comprehensive big-picture-philosophy about how we're going to be part of the solution to escaping URLs, and not more of the problem. :-/

(Also need your matrix chat, getting off of StackOverflow is a priority for the next months!)

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