[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

is this an open-uri bug?

Bradley, Todd

10/29/2004 4:04:00 PM

Hi, I'm new to Ruby and new to using open-uri. But I think I found a
bug. Could someone take a look at this and if this is really a bug,
tell me who to report it to?


Thanks,
Todd.

Here's my little code snippet:


====== code starts ======

require 'open-uri'

string =
"http://www.infospace.com/home/redirect.htm?formfr...&p...
ctory&wqhqn=2&qhqn="
string += "Bubba+Ray+Jackson&qc=Broomfield&qs=co"

puts "\nI'm going to try to open this: #{string}\n\n"

#
# This call throws a URI::InvalidURIError. Is that a bug?
# Looking at the error message, I THINK open_uri is following
# a redirection and somehow mis-parsing the new URI such that
# an erroneous space is inserted.
#
uri = open(string)

====== code ends ======


And here's the output:


I'm going to try to open this:
http://www.infospace.com/home/redirect.htm?formfr...
&pgtarg=directory&wqhqn=2&qhqn=Bubba+Ray+Jackson&qc=Broomfield&qs=co

c:/ruby/lib/ruby/1.8/uri/common.rb:432:in `split': bad URI(is not URI?):
http://...
space.com/home/white-pages/kevdb?kcfg=wpus&otmpl=%2Fwhite-pages%2Fresult
s.htm&qfm=n&qk=10&
top=1&qname=Bubba+Ray+Jackson&qf=Bubba&qn=Ray&qs=co&searchtype=citystate
&QN=Jackson&QF=Bub
ba Ray&qc=Broomfield (URI::InvalidURIError)
from c:/ruby/lib/ruby/1.8/uri/common.rb:481:in `parse'
from c:/ruby/lib/ruby/1.8/open-uri.rb:572:in `proxy_open'
from c:/ruby/lib/ruby/1.8/open-uri.rb:525:in `direct_open'
from c:/ruby/lib/ruby/1.8/open-uri.rb:169:in `open_loop'
from c:/ruby/lib/ruby/1.8/open-uri.rb:164:in `catch'
from c:/ruby/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
from c:/ruby/lib/ruby/1.8/open-uri.rb:134:in `open_uri'
from c:/ruby/lib/ruby/1.8/open-uri.rb:424:in `open'
from c:/ruby/lib/ruby/1.8/open-uri.rb:85:in `open'
from open-uri-bug.rb:14



7 Answers

gabriele renzi

10/29/2004 11:31:00 PM

0

Bradley, Todd ha scritto:

it seem to work for me:
irb(main):001:0> require 'open-uri'
=> true
irb(main):002:0>
irb(main):003:0* string =
irb(main):004:0*
"http://www.infospace.com/home/redirect.htm?formfrom=qsea...
targ=dire
irb(main):005:0" ctory&wqhqn=2&qhqn="
=>
"http://www.infospace.com/home/redirect.htm?formfrom=qsea...targ=dire\ncto
ry&wqhqn=2&qhqn="
irb(main):006:0> string += "Bubba+Ray+Jackson&qc=Broomfield&qs=co"
=>
"http://www.infospace.com/home/redirect.htm?formfrom=qsea...targ=dire\ncto
ry&wqhqn=2&qhqn=Bubba+Ray+Jackson&qc=Broomfield&qs=co"
irb(main):007:0> open(string)
=> #<StringIO:0x2c2efd8>

Tanaka Akira

10/30/2004 3:11:00 PM

0

In article <74297C5A6F930B4CB40D33BD127E882A0DA0E3@WSTEXCH00.westminster.polycom.com>,
"Bradley, Todd" <todd.bradley@Polycom.com> writes:

> Hi, I'm new to Ruby and new to using open-uri. But I think I found a
> bug. Could someone take a look at this and if this is really a bug,
> tell me who to report it to?

It seems that the URI is redirected to invalid URI.

% ./ruby -ropen-uri -e '
class << URI
alias org_parse parse
def parse(arg)
p arg
org_parse(arg)
end
end
open("http://www.infospace.com/home/redirect.htm?formfrom=qsearch&pgtarg=directory&wqhqn=2&qhqn=Bubba+Ray+Jackson&qc=Broomfield&q...)
'
"http://www.infospace.com/home/redirect.htm?formfrom=qsearch&pgtarg=directory&wqhqn=2&qhqn=Bubba+Ray+Jackson&qc=Broomfield&q...
"http://www.infospace.com/home/white-pages/validate.htm?kcfg=wpus&otmpl=%2Fwhite-pages%2Fresults.htm&qfm=n&qk=10&top=1&qname=Bubba+Ray+Jackson&qf=Bubba&qn=Ray&qc=Broomfield&q...
"http://kevdb.infospace.com/home/white-pages/kevdb?kcfg=wpus&otmpl=%2Fwhite-pages%2Fresults.htm&qfm=n&qk=10&top=1&qname=Bubba+Ray+Jackson&qf=Bubba&qn=Ray&qs=co&searchtype=citystate&QN=Jackson&am... Ray&qc=Broomfield"
/home/akr/ruby/tmp-ruby/1.8/lib/ruby/1.8/uri/common.rb:432:in `split': bad URI(is not URI?): http://kevdb.infospace.com/home/white-pages/kevdb?kcfg=wpus&otmpl=%2Fwhite-pages%2Fresults.htm&qfm=n&qk=10&top=1&qname=Bubba+Ray+Jackson&qf=Bubba&qn=Ray&qs=co&searchtype=citystate&QN=Jackson&am... Ray&qc=Broomfield (URI::InvalidURIError)
from /home/akr/ruby/tmp-ruby/1.8/lib/ruby/1.8/uri/common.rb:481:in `org_parse'
from -e:6:in `parse'
from /home/akr/ruby/tmp-ruby/1.8/lib/ruby/1.8/open-uri.rb:572:in `proxy_open'
from /home/akr/ruby/tmp-ruby/1.8/lib/ruby/1.8/open-uri.rb:525:in `direct_open'
from /home/akr/ruby/tmp-ruby/1.8/lib/ruby/1.8/open-uri.rb:169:in `open_loop'
from /home/akr/ruby/tmp-ruby/1.8/lib/ruby/1.8/open-uri.rb:164:in `catch'
from /home/akr/ruby/tmp-ruby/1.8/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
from /home/akr/ruby/tmp-ruby/1.8/lib/ruby/1.8/open-uri.rb:134:in `open_uri'
from /home/akr/ruby/tmp-ruby/1.8/lib/ruby/1.8/open-uri.rb:424:in `open'
from /home/akr/ruby/tmp-ruby/1.8/lib/ruby/1.8/open-uri.rb:85:in `open'
from -e:9

Since the last URI
http://kevdb.infospace.com/home/white-pages/kevdb?kcfg=wpus&otmpl=%2Fwhite-pages%2Fresults.htm&qfm=n&qk=10&top=1&qname=Bubba+Ray+Jackson&qf=Bubba&qn=Ray&qs=co&searchtype=citystate&QN=Jackson&am... Ray&qc=Broomfield
contains a space, URI.parse fails.
--
Tanaka Akira


lindsay_keir

11/25/2004 8:34:00 PM

0

I had this problem. My targeted web page is a bit snitty and insisted on
also receiving a user-agent.

myData = open('http://my.target.site&search..., "User-Agent" => "Ruby/#{RUBY_VERSION}" )
myData.each {|x| puts x + '\n'}

I hope this wasn't too late for you to use.


lindsay_keir

11/25/2004 8:35:00 PM

0

I had this problem. My targeted web page is a bit snitty and insisted on
also receiving a user-agent.

myData = open('http://my.target.site&search..., "User-Agent" => "Ruby/#{RUBY_VERSION}" )
myData.each {|x| puts x + '\n'}

I hope this wasn't too late for you to use.


The Revd

1/5/2013 10:13:00 PM

0

On Sat, 5 Jan 2013 21:31:11 +0000 (UTC), SmallHernia aka HQ
<hq-observer@xxx.yyy> wrote:

>
>In article <686k6u.h0v.17.1@news.alt.net>,
>Walt Hampton <walt.hampton@att.net> wrote:
>
>> (I stopped using the term diaspora to describe the
>> collective of the Jews of the world when my very dear friend
>> Ilan Pappe explained to me why it was wrong to do so.
>
>But Walt, this guy Ilan Pappe is Jewish, therefore you want to
>kill him. How, then, can you call him a "very dear friend", and
>follow his advice?
>
>Cordially, Q.

You need to be ethnically cleansed, jewboi. ASAP!

NoSpamAtAll

1/5/2013 10:20:00 PM

0

In article <0a9he8hqhh49mjnfnvpj7p56jjktl5g4at@4ax.com>,
The Revd <peeling@degenerate.Grik> wrote:

[...]

Stinking limey. You *always* stunk.

http://forums.canadiancontent.net/history/48176-18th-century-london-its-...

"Of every 1,000 children born in early 18th-century London, almost
half died before the age of 2. Malnutrition, maternal ignorance, bad
water, dirty food, poor hygiene and overcrowding all contributed to
this extremely high mortality rate."

The Revd

1/5/2013 10:48:00 PM

0

On Sat, 5 Jan 2013 22:19:51 +0000 (UTC), SmallHernia aka NoSpamAtAll
<spamnot@not.home> wrote:

>In article <0a9he8hqhh49mjnfnvpj7p56jjktl5g4at@4ax.com>,
>The Revd <peeling@degenerate.Grik> wrote:
>
>[...]
>
>Stinking jews. We *always* stunk.
>
>http://forums.canadiancontent.net/history/48176-18th-century-jerusalem-its-...
>
>"Of every 1,000 children born in early 18th-century Jerusalem, almost
>98% died before the age of 2. Malnutrition, jew maternal ignorance, bad
>jew water, dirty jew food, poor jew hygiene and jew overcrowding all contributed to
>this extremely high jew mortality rate."

Only 98%, jewboi? LOL