Read problem with Rebol3

94 views
Skip to first unread message

RaimundD

unread,
Mar 30, 2013, 5:32:49 PM3/30/13
to re...@googlegroups.com
Hi,

I try to convert a script of me from R2 to R3 and have a problem with read.

The command I use is for R2 and R3 identical:

print to-string read to-url "http://download.finance.yahoo.com/d/quotes.csv?s=%5EGDAXI&f=sl1d1t1c1ohgv&e.csv"

and the answer is:

"^GDAXI",7795.31,"3/28/2013","12:45pm",+6.22,7791.14,7842.58,7778.02,0

In R3:
print to-string read to-url "http://download.finance.yahoo.com/d/quotes.csv?s=%5EGDAXI&f=sl1d1t1c1ohgv&e.csv"

and the answer is:

"%5EGDAXI",0.00,"N/A","N/A",N/A,N/A,N/A,N/A,N/A


Does anybody know what is going wrong?

Thanx
Raimund

Ladislav

unread,
Mar 31, 2013, 6:04:12 AM3/31/13
to re...@googlegroups.com


Dne sobota, 30. března 2013 22:32:49 UTC+1 RaimundD napsal(a):
R3 is still alpha and in this case you encountered a case that is not fully working yet, at least that is how it looks at the first sight.

Ladislav 

RaimundD

unread,
Mar 31, 2013, 5:06:14 PM3/31/13
to re...@googlegroups.com
Hi,

I tried to find the problem in the URL because basically READ is working on other URLs.

I finally found the root of the problem:

R2: to-URL "%5"
== %5

R3: to-url "%5"
== %255

So, R3 is converting the % sign inside the URL string. Can I avoid this?

Raimund

John

unread,
Apr 1, 2013, 7:28:26 PM4/1/13
to re...@googlegroups.com
This does appear to be a bug.
Even in the case of a char
R2 gives
>> to-url #"%"
== %
whereas R3 gives
>> to-url #"%"
== %25

All the other chars I tested with R3 seemed to behave correctly such as # or @.

I have raised a bug in curecode so hopefully it will be resolved soon :-)


Thanks,
John

Andreas Bolka

unread,
Apr 1, 2013, 8:00:39 PM4/1/13
to re...@googlegroups.com
> In R3 [..] the answer is:
> "%5EGDAXI",0.00,"N/A","N/A",N/A,N/A,N/A,N/A,N/A
>
> Does anybody know what is going wrong?

At first sight, this looks like a double-encoding issue to me: in your
original URL string, the ^ is already encoded as %5E. When you convert
this string! to an url!, the % gets again encoded as %25.

This is made even more tricky by the fact that ^ is Rebol's own escape
character. Would need further investigation, how to properly construct
an URL containing this character or where this error stems from (but my
bets are on DECODE-URL).

For now, maybe the following workaround is feasible and helps. You can
also pass URLs to READ in a decomposed ("decoded") form:

print to-string read [
scheme: 'http
host: "download.finance.yahoo.com"
path: "/d/quotes.csv?s=^^GDAXI&f=sl1d1t1c1ohgv&e.csv"
]

(This uses the standard ^^ escape for the ^ char in the PATH string!.)

Hope that helps.

--
Regards,
Andreas

John

unread,
Apr 2, 2013, 7:22:53 AM4/2/13
to re...@googlegroups.com
Ok, not a bug, but an improvement.
Reading https://en.wikipedia.org/wiki/Percent-encoding suggests that the behaviour of R3 is correct and R2 is at fault.
This is also the same in other languages such as Ruby
e.g.
>> URI::encode "%"
=> "%25"
It sounds like Andreas has given you a workaround to solve your immediate issue as well.
All good.
Cheers,
John

Ladislav

unread,
Apr 2, 2013, 5:48:01 PM4/2/13
to re...@googlegroups.com


Dne úterý, 2. dubna 2013 13:22:53 UTC+2 John napsal(a):
Ok, not a bug, but an improvement.
Reading https://en.wikipedia.org/wiki/Percent-encoding suggests that the behaviour of R3 is correct and R2 is at fault.
This is also the same in other languages such as Ruby
e.g.
>> URI::encode "%"
=> "%25"
It sounds like Andreas has given you a workaround to solve your immediate issue as well.
All good.
Cheers,
John

On Tuesday, April 2, 2013 10:28:26 AM UTC+11, John wrote:
This does appear to be a bug.
Even in the case of a char
R2 gives
>> to-url #"%"
== %
whereas R3 gives
>> to-url #"%"
== %25

All the other chars I tested with R3 seemed to behave correctly such as # or @.

I have raised a bug in curecode so hopefully it will be resolved soon :-)


Thanks,
John


I wrote http://issue.cc/r3/2010 http://issue.cc/r3/2011 and http://issue.cc/r3/2012 since all of them are implementation problems in my opinion.
Reply all
Reply to author
Forward
0 new messages