mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	updated uri.rb and uri/*.rb to uri-0.9.7
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									396c29d195
								
							
						
					
					
						commit
						05e476c941
					
				
					 5 changed files with 76 additions and 37 deletions
				
			
		|  | @ -15,7 +15,7 @@ | |||
| =end | ||||
| 
 | ||||
| module URI | ||||
|   VERSION_CODE = '000907'.freeze | ||||
|   VERSION_CODE = '000908'.freeze | ||||
|   VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze | ||||
| end | ||||
| 
 | ||||
|  |  | |||
|  | @ -151,8 +151,10 @@ module URI | |||
| 		   (?:(#{PATTERN::HOST})(?::(\\d*))?))?(?# 3: host, 4: port) | ||||
| 	       | | ||||
| 		 (#{PATTERN::REG_NAME})           (?# 5: registry) | ||||
| 	       ))? | ||||
| 	       ((?!//)#{PATTERN::ABS_PATH})?      (?# 6: path) | ||||
| 	       ) | ||||
| 	     | | ||||
| 	     (?!//))                              (?# XXX: '//' is the mark for hostport) | ||||
| 	     (#{PATTERN::ABS_PATH})?              (?# 6: path) | ||||
| 	   )(?:\\?(#{PATTERN::QUERY}))?           (?# 7: query) | ||||
| 	| | ||||
| 	   (#{PATTERN::OPAQUE_PART})              (?# 8: opaque) | ||||
|  | @ -396,23 +398,14 @@ module URI | |||
| =end | ||||
|   def self.extract(str, schemes = []) | ||||
|     urls = [] | ||||
|     if schemes.size > 0 | ||||
|       tmp = Regexp.new('(?:' + schemes.collect{|s|  | ||||
|     regexp = ABS_URI_REF | ||||
|     unless schemes.empty? | ||||
|       regexp = Regexp.new('(?=' + schemes.collect{|s|  | ||||
| 			    Regexp.quote(s + ':') | ||||
| 		       }.join('|') + ')',  | ||||
| 			  }.join('|') + ')' + PATTERN::X_ABS_URI,  | ||||
| 			  Regexp::IGNORECASE, 'N') | ||||
|       str.scan(tmp) { | ||||
| 	tmp_str = $& + $' | ||||
| 	if ABS_URI_REF =~ tmp_str | ||||
| 	  if block_given? | ||||
| 	    yield($&) | ||||
| 	  else | ||||
| 	    urls << $& | ||||
|     end | ||||
| 	end | ||||
|       } | ||||
| 
 | ||||
|     else | ||||
|     str.scan(ABS_URI_REF) { | ||||
|       if block_given? | ||||
| 	yield($&) | ||||
|  | @ -420,7 +413,6 @@ module URI | |||
| 	urls << $& | ||||
|       end | ||||
|     } | ||||
|     end | ||||
| 
 | ||||
|     if block_given? | ||||
|       return nil | ||||
|  |  | |||
|  | @ -183,6 +183,18 @@ Object | |||
|     attr_reader :opaque | ||||
|     attr_reader :fragment | ||||
| 
 | ||||
|     # replace self by other URI object | ||||
|     def replace!(oth) | ||||
|       if self.class != oth.class | ||||
| 	raise ArgumentError, "expected #{self.class} object" | ||||
|       end | ||||
| 
 | ||||
|       component.each do |c| | ||||
| 	self.__send__("#{c}=", oth.__send__(c)) | ||||
|       end | ||||
|     end | ||||
|     private :replace! | ||||
| 
 | ||||
| =begin | ||||
| 
 | ||||
| === Instance Methods | ||||
|  | @ -436,7 +448,13 @@ Object | |||
|     private :check_port | ||||
| 
 | ||||
|     def set_port(v) | ||||
|       v = v.to_i if v && !v.kind_of?(Fixnum) | ||||
|       unless !v || v.kind_of?(Fixnum) | ||||
| 	if v.empty? | ||||
| 	  v = nil | ||||
| 	else | ||||
| 	  v = v.to_i | ||||
| 	end | ||||
|       end | ||||
|       @port = v | ||||
|     end | ||||
|     protected :set_port | ||||
|  | @ -683,6 +701,7 @@ Object | |||
| =begin | ||||
| 
 | ||||
| --- URI::Generic#merge(rel) | ||||
| --- URI::Generic#merge!(rel) | ||||
| --- URI::Generic#+(rel) | ||||
| 
 | ||||
| =end | ||||
|  | @ -750,6 +769,16 @@ Object | |||
|     end | ||||
|     private :merge_path | ||||
| 
 | ||||
|     def merge!(oth) | ||||
|       t = merge(oth) | ||||
|       if self == t | ||||
| 	nil | ||||
|       else | ||||
| 	replace!(t) | ||||
| 	self | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     # abs(self) + rel(oth) => abs(new) | ||||
|     def merge(oth) | ||||
|       base, rel = merge0(oth) | ||||
|  | @ -1084,6 +1113,20 @@ Object | |||
|       to_ary | ||||
|     end | ||||
| 
 | ||||
| =begin | ||||
| --- URI::Generic#select(*components) | ||||
| =end | ||||
|     def select(*components) | ||||
|       components.collect do |c| | ||||
| 	if component.include?(c) | ||||
| 	  self.send(c) | ||||
| 	else | ||||
| 	  raise ArgumentError,  | ||||
| 	    "expected of components of #{self.class} (#{self.class.component.join(', ')})" | ||||
| 	end | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
| =begin | ||||
| =end | ||||
|     def inspect | ||||
|  |  | |||
|  | @ -134,6 +134,7 @@ URI::LDAP is copyrighted free software by Takaaki Tateishi and akira yamada. | |||
|     def set_dn(val) | ||||
|       @dn = val | ||||
|       build_path_query | ||||
|       @dn | ||||
|     end | ||||
|     protected :set_dn | ||||
| 
 | ||||
|  | @ -156,6 +157,7 @@ URI::LDAP is copyrighted free software by Takaaki Tateishi and akira yamada. | |||
|     def set_attributes(val) | ||||
|       @attributes = val | ||||
|       build_path_query | ||||
|       @attributes | ||||
|     end | ||||
|     protected :set_attributes | ||||
| 
 | ||||
|  | @ -178,6 +180,7 @@ URI::LDAP is copyrighted free software by Takaaki Tateishi and akira yamada. | |||
|     def set_scope(val) | ||||
|       @scope = val | ||||
|       build_path_query | ||||
|       @scope | ||||
|     end | ||||
|     protected :set_scope | ||||
| 
 | ||||
|  | @ -200,6 +203,7 @@ URI::LDAP is copyrighted free software by Takaaki Tateishi and akira yamada. | |||
|     def set_filter(val) | ||||
|       @filter = val | ||||
|       build_path_query | ||||
|       @filter | ||||
|     end | ||||
|     protected :set_filter | ||||
| 
 | ||||
|  | @ -222,6 +226,7 @@ URI::LDAP is copyrighted free software by Takaaki Tateishi and akira yamada. | |||
|     def set_extensions(val) | ||||
|       @extensions = val | ||||
|       build_path_query | ||||
|       @extensions | ||||
|     end | ||||
|     protected :set_extensions | ||||
| 
 | ||||
|  |  | |||
|  | @ -46,22 +46,21 @@ module URI | |||
|     # hname      =  *urlc | ||||
|     # hvalue     =  *urlc | ||||
|     # header     =  hname "=" hvalue | ||||
|     header_pattern = "(?:[^?=&]*=[^?=&]*)" | ||||
|     HEADER_REGEXP = /#{header_pattern}/ | ||||
|     HEADER_PATTERN = "(?:[^?=&]*=[^?=&]*)".freeze | ||||
|     HEADER_REGEXP  = Regexp.new(HEADER_PATTERN, 'N').freeze | ||||
|     # headers    =  "?" header *( "&" header ) | ||||
|     # to         =  #mailbox | ||||
|     # mailtoURL  =  "mailto:" [ to ] [ headers ] | ||||
|     mailbox_pattern = "(?:[^(),%?=&]|#{PATTERN::ESCAPED})" | ||||
|     MAILBOX_REGEXP = /#{mailbox_pattern}/ | ||||
|     MAILBOX_PATTERN = "(?:[^(),%?=&]|#{PATTERN::ESCAPED})".freeze | ||||
|     MAILTO_REGEXP = Regexp.new(" | ||||
|       \\A | ||||
|       (#{mailbox_pattern}*?)                         (?# 1: to) | ||||
|       (#{MAILBOX_PATTERN}*?)                          (?# 1: to) | ||||
|       (?: | ||||
|         \\? | ||||
|         (#{header_pattern}(?:\\&#{header_pattern})*) (?# 2: headers) | ||||
|         (#{HEADER_PATTERN}(?:\\&#{HEADER_PATTERN})*)  (?# 2: headers) | ||||
|       )? | ||||
|       \\z | ||||
|     ", Regexp::EXTENDED, 'N') | ||||
|     ", Regexp::EXTENDED, 'N').freeze | ||||
| 
 | ||||
| =begin | ||||
| 
 | ||||
|  | @ -155,7 +154,7 @@ module URI | |||
|       return true unless v | ||||
|       return true if v.size == 0 | ||||
| 
 | ||||
|       if OPAQUE !~ v || /\A#{MAILBOX_REGEXP}*\z/o !~ v | ||||
|       if OPAQUE !~ v || /\A#{MAILBOX_PATTERN}*\z/o !~ v | ||||
| 	raise InvalidComponentError, | ||||
| 	  "bad component(expected opaque component): #{v}" | ||||
|       end | ||||
|  | @ -191,7 +190,7 @@ module URI | |||
|       return true if v.size == 0 | ||||
| 
 | ||||
|       if OPAQUE !~ v ||  | ||||
| 	  /\A(#{HEADER_REGEXP}(?:\&#{HEADER_REGEXP})*)\z/o !~ v | ||||
| 	  /\A(#{HEADER_PATTERN}(?:\&#{HEADER_PATTERN})*)\z/o !~ v | ||||
| 	raise InvalidComponentError, | ||||
| 	  "bad component(expected opaque component): #{v}" | ||||
|       end | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 akira
						akira