Bug #6420
closedundefined local variable or method `parser' for URI::Generic:Class
Description
=begin
When using the URI::Generic.build2 class method, if a URL component needs to be escaped (space -> %20, for example), it will attempt to call parser.escape on it. This generates an exception of "undefined local variable or method `parser' for URI::Generic:Class" because there is no parser class method. I expected it to return a URI instance with the components properly escaped.
I'm going to submit a pull request on the GitHub mirror that adds this class method and restores the expected behavior.
Code to reproduce:
(({URI::Generic.build2(path: "/foo bar/baz"}))
The space in "foo bar" needs to be escaped in that example, triggering the bug.
=end
Files
        
          
          Updated by cap10morgan (Wes Morgan) over 13 years ago
          
          
        
        
      
      =begin
Obviously that code line above should read:
(({URI::Generic.build2(path: "/foo bar/baz")}))
=end
        
          
          Updated by cap10morgan (Wes Morgan) over 13 years ago
          
          
        
        
      
      Pull request issued: https://github.com/ruby/ruby/pull/124
        
          
          Updated by zzak (zzak _) over 13 years ago
          
          
        
        
      
      I've added Wes' patch from GH#124
        
          
          Updated by ayumin (Ayumu AIZAWA) over 13 years ago
          
          
        
        
      
      - Status changed from Open to Assigned
 - Assignee set to akira (akira yamada)
 
        
          
          Updated by naruse (Yui NARUSE) over 13 years ago
          
          
        
        
      
      - Status changed from Assigned to Closed
 - % Done changed from 0 to 100
 
This issue was solved with changeset r35692.
Wes, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- 
lib/uri/generic.rb (URI::Generic.build): duplicate args before adding
new items. (don't change arguments) - 
lib/uri/generic.rb (URI::Generic.build): use URI::Generic::COMPONENT
if this method is called from URI::Generic. - 
lib/uri/generic.rb (URI::Generic.build2): escape only if the item is
a String. - 
lib/uri/generic.rb (URI::Generic.build2): use DEFAULT_PARSER because
it doesn't have parser method. [Bug #6420]