Commit graph

128 commits

Author SHA1 Message Date
Nobuyoshi Nakada
d147091418 [ruby/uri] [DOC] Document private visibility too
For the references to URI::RFC2396_Parser private methods.

372fbb455d
2025-07-14 05:11:58 +00:00
Nobuyoshi Nakada
4b1de7378d [ruby/uri] [DOC] State that uri library is needed to call Kernel#URI
So that the example works as-is.

30212d311e
2025-06-26 01:46:48 +00:00
Nobuyoshi Nakada
4eba511c1b [ruby/uri] Fix a typo
b636e83d99

Co-authored-by: Olle Jonsson <olle.jonsson@gmail.com>
2025-06-26 01:39:20 +00:00
Nobuyoshi Nakada
228cc794f5 [ruby/uri] Use Lo category chars as escaped chars
TruffleRuby does not allow Symbol categories as identifiers.

5531d42375
2025-06-26 01:39:20 +00:00
Nobuyoshi Nakada
42f753d829 [ruby/uri] Escape reserved characters in scheme name
Fix https://github.com/ruby/uri/pull/89

d543c0dafa
2025-06-26 01:39:19 +00:00
yuuji.yaginuma
75f07afd18 [ruby/uri] Use a fully qualified name in warning messages
Currently, some warning messages don't contain a `URI` like the following.

```ruby
warning: URI::ABS_URI is obsolete. Use RFC2396_PARSER.regexp[:ABS_URI] explicitly.
```

But, without `URI` prefix, the suggested value doesn't work.
So I think we should use a fully qualified name to avoid confusion.

428eb10e44
2025-02-27 04:32:27 +00:00
Nobuyoshi Nakada
881924f259 [ruby/uri] [DOC] Make documentation 100%
fe7aa3dac2
2025-01-24 01:45:08 +00:00
Hiroshi SHIBATA
310e6603a2 [ruby/uri] Check existence constants only URI module
b6f583369a
2024-11-14 03:32:13 +00:00
Hiroshi SHIBATA
1bab8bf88f [ruby/uri] Removed duplicated declare step for constants under the URI::RFC2396_REGEXP::PATTERN
60a8bc1575
2024-11-14 02:20:04 +00:00
Hiroshi SHIBATA
d7c65398e0 [ruby/uri] Added more fallback constants like URI::PARTTERN and URI::REGEXP
Fixed https://github.com/ruby/uri/issues/125

1f3d3df02a
2024-11-08 06:06:30 +00:00
Hiroshi SHIBATA
267da552a1 [ruby/uri] Fallback missing constants with RFC3986_PARSER
(https://github.com/ruby/uri/pull/113)

* Fallback missing constants with RFC3986_PARSER

* raise missing constant

* Update test/uri/test_common.rb

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

* Update lib/uri/common.rb

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

* Update lib/uri/common.rb

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

---------

c2fdec079a

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-08-06 09:09:52 +00:00
Hiroshi SHIBATA
a82976bc90 [ruby/uri] Use DEFAULT_PARSER at split, parse, join
28af4e155a
2024-08-05 08:00:14 +00:00
Randy Stauner
da49bee04b [ruby/uri] Restrict constant checks to current namespace to avoid conflicts with globals
7a64e0245f
2024-07-21 16:57:32 +00:00
Hiroshi SHIBATA
8db2325a11 [ruby/uri] Also support URI::PATTERN with switch-back
823697edb4
2024-07-19 00:50:38 +00:00
Hiroshi SHIBATA
082335494b [ruby/uri] Added test for constant definition and remove URI::REGEXP when using RFC3986_PARSER
6f616d97fc
2024-07-19 00:50:37 +00:00
Hiroshi SHIBATA
08e449d89b [ruby/uri] Added URI.parser= method for switch back to RFC2396_Parser
d7dc19ad3f
2024-07-19 00:50:35 +00:00
Burdette Lamar
41a947e72a [ruby/uri] [DOC] Enhanced RDoc for URI
(https://github.com/ruby/uri/pull/55)

89ab4f1407
2023-01-08 23:14:50 +00:00
Burdette Lamar
20b691d664 [ruby/uri] [DOC] Enhanced RDoc for URI.decode_www_form
(https://github.com/ruby/uri/pull/53)

ce379e6125
2023-01-08 17:11:12 +00:00
Burdette Lamar
fd98169e00 [ruby/uri] [DOC] Common rdoc (https://github.com/ruby/uri/pull/52)
be8047028f
2023-01-07 19:22:36 +00:00
Burdette Lamar
ddbf7be94d [ruby/uri] [DOC] Enhanced RDoc for common methods
(https://github.com/ruby/uri/pull/50)

7ff4fb372b
2023-01-06 14:20:38 +00:00
Burdette Lamar
f7243d1afb [ruby/uri] [DOC] Common methods rdoc
(https://github.com/ruby/uri/pull/49)

02dfc79366
2023-01-04 19:59:05 +00:00
Burdette Lamar
59cf9ebf4d [ruby/uri] [DOC] Enhanced RDoc for common methods
(https://github.com/ruby/uri/pull/48)

2bfd848c26
2023-01-03 15:33:45 +00:00
Benoit Daloze
40ca208a6d [ruby/uri] Improve URI.register_scheme tests and automatically upcase the given scheme
* Also add docs and mention current limitations.
* For reference, https://stackoverflow.com/a/3641782/388803 mentions the
  valid characters in schemes.

4346daac75
2022-05-12 18:19:17 +09:00
Jeremy Evans
fbebfe1697 [ruby/uri] Add URI::Generic#decoded_#{user,password}
URI::Generic#{user,password} return the encoded values, which are
not that useful if you want to do authentication with them.
Automatic decoding by default would break backwards compatibility.
Optional automatic decoding via a keyword to URI.parse would
require threading the option through at least 3 other methods, and
would make semantics confusing (user= takes encoded or unencoded
password?) or require more work.  Thus, adding this as a separate
method seemed the simplest approach.

Unfortunately, URI lacks a method for correct decoding.  Unlike in
www form components, + in earlier parts of the URI such as the
userinfo section is treated verbatim and not as an encoded space.
Add URI.#{en,de}code_uri_component methods, which are almost the
same as URI.#{en,de}code_www_form_component, but without the
special SP => + handling.

Implements [Feature #9045]

16cfc4e92f
2022-05-12 14:54:37 +09:00
Peter Zhu
eab354e17b [ruby/uri] Include RFC2396_REGEXP module directly
REGEXP is defined as RFC2396_REGEXP in lib/uri/common.rb. If we include
REGEXP then a broken URL is generated in rdoc for URI and URI::MailTo.

ed6ded9c80
2022-04-22 12:00:14 +09:00
Benoit Daloze
59a65f2d24 Update to latest uri
* bc47bf71df
* To include the fix from https://github.com/ruby/uri/pull/27
2021-07-28 12:26:31 +02:00
Hiroshi SHIBATA
6656309fe2
Fix test failure for parallel testing 2021-07-27 17:34:13 +09:00
Benoit Daloze
1cf111774f
[ruby/uri] Add proper Ractor support to URI
* Using a module to map scheme name to scheme class, which also works with Ractor.
* No constant redefinition, no ObjectSpace, still fast lookup for initial schemes.

883567fd81
2021-07-27 16:54:27 +09:00
Benoit Daloze
090d799c24
[ruby/uri] Revert "Fix to support Ruby 3.0 Ractor"
* This reverts commit 1faa4fdc161d7aeebdb5de0c407b923beaecf898.
* It has too many problems, see https://github.com/ruby/uri/pull/22 for discussion.

b959da2dc9
2021-07-27 16:54:26 +09:00
kvokka
a288c21a5d
[ruby/uri] Fix to support Ruby 3.0 Ractor
1faa4fdc16
2021-07-27 16:54:26 +09:00
Steven Harman
bbee6968f8 [ruby/uri] Use Regexp#match? to avoid extra allocations
`#=~` builds `MatchData`, requiring extra allocations as compared to
`#match?`, which returns a boolean w/o having to build the `MatchData`.

158f58a9cc
2021-04-22 14:55:44 +09:00
d-m-u
ccf9da079f fix doc typo
s/it's/its
2020-12-16 23:22:15 -05:00
Jeremy Evans
abbd324152 [ruby/uri] Remove deprecated URI.escape/URI.unescape
61c6a47ebf
2020-09-15 21:17:20 +09:00
Kazuhiro NISHIYAMA
16bc9bf7e8
[DOC] Use https:// instead of http:// [ci skip] 2020-07-13 11:33:40 +09:00
git
b0b6d0a688 * remove trailing spaces. [ci skip] 2020-03-26 18:06:32 +09:00
David Rodríguez
9e8d75e881
[ruby/uri] Remove RCS keywords
1bcb1203ad
2020-03-26 18:06:14 +09:00
Samuel Williams
844ff7ea45
[ruby/uri] Simplify construction of URI instances using parser interface.
c145017dd7
2020-03-26 18:06:14 +09:00
Jeremy Evans
d3b28ebc7a Fix warnings for URI.encode and URI.decode
Use __callee__ to display the called method.

Fixes [Bug #16469]
2020-01-09 13:09:06 -08:00
Jeremy Evans
869e2dd8c8 Warn for URI.{,un}{escape,encode}, even if not in verbose mode
The verbose mode warning has been present for almost 10 years.
If we ever plan to remove these methods, we should make the warning
a regular deprecation warning so that people are aware.

Implements [Feature #15961]
2019-09-27 07:43:32 -07:00
Jeremy Evans
a2c26fe1c6 Fix fallback in URI.encode_www_form_component to include #
Patch from Matthew Kerwin.

Fixes [Bug #14358]
2019-09-27 07:43:32 -07:00
marcandre
e859e668d2 lib/*: Prefer require_relative over require.
[#15206] [Fix GH-1976]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-02 17:52:33 +00:00
nobu
27e972854c common.rb: unused constant
* lib/uri/common.rb (URI::HTML5ASCIIINCOMPAT): remove the constant
  which has been unused since r40460, and wrong since r49069 due
  to the operator precedence.  [ruby-core:86678] [Bug #14711]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-25 11:56:58 +00:00
stomar
300b22dc22 Improve docs for URI library
* lib/uri/generic.rb: [DOC] fix invalid example code to make it
  syntax highlighted; drop unnecessary `puts', `p'; adapt to current
  inspect format without Object id; do not display unnecessary return
  values in examples; fix or prevent unintended description lists;
  fix broken RDoc; fix grammar and typos.

* lib/uri.rb: ditto.
* lib/uri/common.rb: ditto.
* lib/uri/file.rb: ditto.
* lib/uri/ftp.rb: ditto.
* lib/uri/http.rb: ditto.
* lib/uri/ldap.rb: ditto.
* lib/uri/mailto.rb: ditto.
* lib/uri/rfc2396_parser.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-21 20:04:05 +00:00
normal
26b3dc4922 uri/common: reduce allocations and retained objects
Thanks to Sam Saffron for this patch, it shows
a nice reduction which affects many web applications:

  require 'memory_profiler'

  MemoryProfiler.report do
    require 'uri'
  end.pretty_print

Before:

Total allocated: 986643 bytes (15159 objects)
Total retained:  246370 bytes (2532 objects)

After:

Total allocated: 926903 bytes (13665 objects)
Total retained:  208570 bytes (1587 objects)

* lib/uri/common.rb: reduce allocations and retained objects
  [ruby-core:85161] [Feature #14410]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-28 21:07:13 +00:00
shyouhei
f2a91397fd Add uplevel keyword to Kernel#warn and use it
If uplevel keyword is given, the warning message is prepended
with caller file and line information and the string "warning: ".
The use of the uplevel keyword makes Kernel#warn format output
similar to how rb_warn formats output.

This patch modifies net/ftp and net/imap to use Kernel#warn
instead of $stderr.puts or $stderr.printf, since they are used
for printing warnings.

This makes lib/cgi/core and tempfile use $stderr.puts instead of
warn for debug logging, since they are used for debug printing
and not for warning.

This does not modify bundler, rubygems, or rdoc, as those are
maintained outside of ruby and probably wish to remain backwards
compatible with older ruby versions.

rb_warn_m code is originally from nobu, but I've changed it
so that it only includes the path and lineno from uplevel
(not the method), and also prepends the string "warning: ",
to make it more similar to rb_warn.

From: Jeremy Evans code@jeremyevans.net
Signed-off-by: Urabe Shyouhei shyouhei@ruby-lang.org


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 11:56:25 +00:00
kazu
dabdec31e4 Use caller with length to reduce unused strings
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 14:40:03 +00:00
sonots
10ee38b6bc * lib/uri/common.rb: [DOC] add rdoc to describe
URI.unescape is obsolete [ci-skip] [fix GH-1630]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26 06:42:11 +00:00
naruse
6219b68fb5 Fix typo of URI#escape [Bug #13147]
patched by Steve Hill <sghill.dev@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-23 17:02:08 +00:00
a_matsuda
41cc7eaa7e Update comment about default constant
Patch by: Dave Takahashi <dtcello@gmail.com> (@dtakahas)
Signed-off-by: Akira Matsuda <ronnie@dio.jp>

closes #1151

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-08 11:57:00 +00:00
hsbt
13e474f035 * lib/uri/common.rb: added documentation for deprecated method.
[Misc #11960][ruby-core:72733][ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-20 08:03:01 +00:00