Граф коммитов

86 Коммитов

Автор SHA1 Сообщение Дата
knu b53ec390d1 Allow empty path components in a URI [Bug #8352]
* generic.rb (URI::Generic#merge, URI::Generic#route_to): Fix a bug
  where a sequence of slashes in the path part gets collapsed to a
  single slash.  According to the relevant RFCs and WHATWG URL
  Standard, empty path components are simply valid and there is no
  special treatment defined for them, so we just keep them as they
  are.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14 01:11:28 +00:00
naruse ed48bfa5e8 Append "//" if empty host for file or postgres URI
https://url.spec.whatwg.org/#url-serializing
> Otherwise, if url’s host is null and url’s scheme is "file", append "//" to output.

URL spec doesn't says anything about postgres, but assume the same thing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01 15:09:41 +00:00
naruse ec7c76c446 URI::Generic: Separate no_proxy handling
To share with Net::HTTP. see #11195

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-28 10:51:31 +00:00
nobu 556e3da421 uri/generic.rb: fix exception on non-IP format
* lib/uri/generic.rb (URI::Generic#find_proxy): match IP address
  no_proxy against resolved self IP address.  [Fix GH-1513]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-17 12:54:35 +00:00
nobu ba71a68732 test_mailto.rb: overwritten methods
* test/uri/test_mailto.rb (URI::TestMailTo#test_to_mailtext):
  merge overwritten methods.  [Bug #10774]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-17 00:58:47 +00:00
nobu a37cc2d4d8 test_mailto.rb: adjust scope
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-17 00:58:46 +00:00
naruse 6c0aece53d Use URI.decode_www_form_component [Bug #10774]
`parser` refered RFC2396_Parser, but it is separated.
test is contributed by Dominik Menke

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-12 15:24:28 +00:00
kazu c29026204e fix warning: assigned but unused variable
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-12 15:28:03 +00:00
kazu 0c7a092dd2 do not need to downcase twice
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-12 15:28:01 +00:00
akr 2db9a0db99 Test URI.find_proxy using env argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-11 17:23:29 +00:00
hsbt 107ba65fba * lib/uri/http.rb: Documentation and code style imrovements.
* test/uri/test_http.rb: Added test for coverage.
  [fix GH-1427][ruby-core:77255][Misc #12756]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-30 10:06:24 +00:00
tenderlove c2cbd5528c Don't include bad password in URI exception output
We shouldn't include the bad password in the URI exception output
message.  Just knowing that there is a bad password is enough
information.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-15 21:44:56 +00:00
hsbt 52f9d387e6 * lib/uri/mailto.rb: Removed needless `return` and use `.`` instead of `::`
with class method.
* test/uri/test_mailto.rb: Added tests for coverage.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-12 04:46:27 +00:00
naruse 79f86a67d0 * lib/uri/mailto.rb (initialize): RFC3986_Parser#split sets opaque
only if the URI has path-rootless, not path-empty.
  [ruby-core:76055] [Bug #12498]
  patched by Chris Heisterkamp <cheister@squareup.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-02 09:05:05 +00:00
nobu 1ee9cad027 CIDR in no_proxy
* lib/uri/generic.rb (URI::Generic#find_proxy): support CIDR in
  no_proxy.  [ruby-core:73769] [Feature#12062]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-13 08:31:12 +00:00
nobu 423d042371 no_proxy with whitespaces and leading dots
* lib/uri/generic.rb (find_proxy): exclude white-spaces and allow
  for a leading dot in the domain name in no_proxy.
  [ruby-core:54542] [Feature #8317]

The previous implementation wouldn't allow for white-spaces nor a leading dot
in the domain name. The latter is described in the wget documentation as a valid case.

By being more strict on the characters, which are counted to a domainname,
we allow for white-spaces.
Also, a possible leading dot will be handled gracefully.

[Fix GH-285]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-13 08:12:21 +00:00
nobu 1b6684f878 test/uri/test_generic.rb: split test_find_proxy
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-13 07:52:25 +00:00
nobu 1a222cd357 domainname no_proxy assertions
* test/uri/test_generic.rb (test_find_proxy): assertions for
  no_proxy of domainname.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-13 02:00:54 +00:00
naruse aa90e3b859 * lib/uri/generic.rb (URI::Generic#to_s): change encoding to
UTF-8 as Ruby 2.2/ by Koichi ITO <koic.ito@gmail.com>
  https://github.com/ruby/ruby/pull/1188 fix GH-1188

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-14 11:20:24 +00:00
naruse 3e92b635fb Add frozen_string_literal: false for all files
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
nobu ec74d507fe test_generic.rb: fix assertion
* test/uri/test_generic.rb (test_to_s): use assert_not_predicate.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 23:48:37 +00:00
normal 0df938d5be test/uri/test_generic.rb (to_s): new test
Ensure URI::Generic#to_s continues to return mutable strings to
prevent breakage when we enable frozen string literals in future
commits.

[ruby-core:71820]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 21:27:34 +00:00
naruse 8c7310e713 * lib/uri/rfc2396_parser.rb (initialize_pattern):
URI::Generic.build should accept port as a string.
  pattern[:PORT] is not defined for long.
  by Dave Slutzkin <daveslutzkin@fastmail.fm>
  https://github.com/ruby/ruby/pull/804 fix GH-804

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-19 02:34:47 +00:00
duerst e3c4c7e13b * lib/uri/mailto.rb: raising URI::InvalidComponentError instead
of failing with undefined method `split' for nil:NilClass for
  mailto: URIs without opaque part. [Bug #10738]
* test/uri/testuri.rb: Test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-14 09:06:13 +00:00
naruse 30fef86b38 * lib/uri/generic.rb (URI::Generic#query=): don't escape [\]^
on both rfc2396 and rfc3986. [Bug #10619]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-23 13:11:43 +00:00
naruse e1606f920b * lib/uri/generic.rb (URI::Generic.build):
use hostname= to detect and wrap IPv6 hosts.
  Build is accepting URI components and users may not expect
  that a host component needs to be wrapped with square brackets
  since it's not providing a URI.
  Note: initialize with arg_check => true does not wrap IPv6 hosts.
  by Joe Rafaniello <jrafanie@redhat.com>
  https://github.com/ruby/ruby/pull/765 fix GH-765

* test/uri/test_generic.rb: Add more tests

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 17:36:54 +00:00
akr fb2008a73a * test/lib/envutil.rb: Moved from test/ruby/.
* test/lib/find_executable.rb: Ditto.

* test/lib/memory_status.rb: Ditto.

* test/lib/test/unit.rb: require envutil.

* test/: Don't require envutil in test files.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13 16:05:37 +00:00
naruse 21ab98a997 * lib/uri/rfc3986_parser.rb (URI::RFC3986_Parser::RFC3986_URI):
allow '[' and ']' for URI input (and escape). [Bug #10402]

* lib/uri/generic.rb (URI#query=): escape '[', '\', and ']'.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-03 00:33:47 +00:00
glass a4645e5612 * lib/uri/rfc3986_parser.rb: raise URI::InvalidURIError when
uri doesn't respond to #to_str. [ruby-core:64453] [Bug #10150]

* test/uri/test_parser.rb: test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-27 03:13:22 +00:00
naruse e37aab94da * lib/uri/rfc3986_parser.rb: specify a regexp for :OPAQUE; generic.rb
assumes it is present, and will refuse all values otherwise.
  by Matthew Draper <matthew@trebex.net>
  https://github.com/ruby/ruby/pull/718 fix GH-718

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-17 14:15:03 +00:00
nobu 682f3a7881 uri/common.rb: use negative look-ahead
* lib/uri/common.rb (URI.decode_www_form_component): use negative
  look-ahead instead of nested repeat operators, to get rid of
  backtrack explosion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-25 07:29:50 +00:00
naruse 7af7388202 * lib/uri/generic.rb (URI::Generic#query=): remove validation, just
escape. [Feature #2542]

* lib/uri/generic.rb (URI::Generic#fragment=): ditto.

* lib/uri/generic.rb (URI::Generic#check_query): removed.

* lib/uri/generic.rb (URI::Generic#set_query): ditto.

* lib/uri/generic.rb (URI::Generic#check_fragment): ditto.

* lib/uri/generic.rb (URI::Generic#set_fragment): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-03 18:00:08 +00:00
naruse e63ab5d3ad * lib/uri/mailto.rb: update to latest specs, RFC 6068 and HTML5.
* lib/uri/mailto.rb (HEADER_PATTERN): removed.

* lib/uri/mailto.rb (HEADER_REGEXP): use RFC 6068 hfields.

* lib/uri/mailto.rb (EMAIL_REGEXP): use HTML5 email regexp.

* lib/uri/mailto.rb (URI::MailTo.build): support multiple to addresses.

* lib/uri/mailto.rb (URI::MailTo#initialize): Support multiple to
  addresses. Don't check with regexp, only split.

* lib/uri/mailto.rb (URI::MailTo#check_to): verify by matching
  URI path-rootless and HTML5 email regexp with unescaped one.

* lib/uri/mailto.rb (URI::MailTo#check_headers): verify only by
  HEADER_REGEXP.

* lib/uri/mailto.rb (URI::MailTo#set_headers): don't check by
  HEADER_REGEXP, only split it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-27 19:26:43 +00:00
naruse 36a043a93a suppress warnings: URI.regexp is obsolete
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-27 06:25:44 +00:00
naruse a054854324 Revert "* lib/uri/mailto.rb: support RFC6068."
to fix mailto URI syntax

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-24 02:58:45 +00:00
nobu 195bee47b7 * test/uri/test_common.rb: use `require_relative` for parallel test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23 21:57:23 +00:00
naruse a672789739 * lib/uri/mailto.rb: support RFC6068.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23 20:01:27 +00:00
naruse e02eb253e7 * lib/uri/generic.rb (check_port): allow strings for port= as
described in rdoc.

* lib/uri/rfc3986_parser.rb (regexp): implementation detail of above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23 03:18:51 +00:00
naruse 66aba8cca2 suppress warnings of URI.extract
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23 03:18:17 +00:00
naruse bb83f32dc3 support RFC3986 [Feature #2542]
* lib/uri/common.rb (URI::REGEXP): move to lib/uri/rfc2396_parser.rb.

* lib/uri/common.rb (URI::Parser): ditto.

* lib/uri/common.rb (URI.split): use RFC3986_Parser.

* lib/uri/common.rb (URI.parse): ditto.

* lib/uri/common.rb (URI.join): ditto.

* lib/uri/common.rb (URI.extract): deprecated.

* lib/uri/common.rb (URI.regexp): ditto.

* lib/uri/rfc2396_parser.rb: added.

* lib/uri/rfc3986_parser.rb: added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-22 00:22:19 +00:00
hsbt e5af180eb0 * test/uri/test_generic.rb: fix wrong arguments for test case.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-16 09:23:02 +00:00
knu d3edb4a85e * test/uri/test_generic.rb (URI#test_merge): Test uri + URI(path)
in addition to uri + path.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 07:26:53 +00:00
naruse 80d8216415 * lib/uri/generic.rb (URI::Generic.find_proxy): return nil if
http_proxy environment variable is empty string.
  [ruby-core:57140] [Bug #8898]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-13 04:57:25 +00:00
sorah b30a172385 * lib/uri/common.rb (URI.decode_www_form_component):
Don't raise error when str includes multibyte characters.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 09:00:18 +00:00
naruse 6398f79853 * lib/uri/generic.rb (find_proxy): raise BadURIError if the URI is
a relative URI. [Bug #8645]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-24 10:52:15 +00:00
naruse 53fdb30e7f * lib/uri/common.rb (URI.decode_www_form): scrub string if decoded
bytes are invalid for the encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-18 18:58:13 +00:00
naruse 4a50d447d9 * lib/uri/common.rb (URI.decode_www_form): follow current URL Standard.
It gets encoding argument to specify the character encoding.
  It now allows loose percent encoded strings, but denies ;-separator.
  [ruby-core:53475] [Bug #8103]

* lib/uri/common.rb (URI.decode_www_form): follow current URL Standard.
  It gets encoding argument to convert before percent encode.
  Now UTF-16 strings aren't converted to UTF-8 before percent encode
  by default.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-25 05:27:41 +00:00
naruse 37cc18d54b * lib/uri/ftp.rb (URI::FTP#initialize): raise InvalidURIError if "//"
is not present [ruby-core:47344] [Bug #6945]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-30 00:22:11 +00:00
kazu 216b833003 * test/uri/test_generic.rb (URI#test_find_proxy): add tests with empty *_proxy env variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-22 16:55:55 +00:00
kazu 89a030795a fix failures
* test/uri/test_generic.rb (URI#with_env): unset proxy related env
  variables.  [Bug #6774]

* test/uri/test_generic.rb (URI#test_find_proxy): fix failures
  when proxy related env variables already set.  [Bug #6774]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-22 16:50:49 +00:00