Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: character class has duplicated range #437

Closed
ukolovda opened this issue Oct 8, 2021 · 2 comments
Closed

warning: character class has duplicated range #437

ukolovda opened this issue Oct 8, 2021 · 2 comments

Comments

@ukolovda
Copy link
Contributor

ukolovda commented Oct 8, 2021

I've got the error
"warning: character class has duplicated range"

I found that Addressable::URI::CharacterClasses::AUTHORITY has redundant colon:

PCHAR = UNRESERVED + SUB_DELIMS + "\\:\\@"
...
AUTHORITY = PCHAR + "\\[\\:\\]"

See

AUTHORITY = PCHAR + "\\[\\:\\]"

Ruby 3.0.2 give this warning.

@dentarg
Copy link
Collaborator

dentarg commented Oct 8, 2021

How to reproduce:

$ ruby -w -raddressable/uri -e 'Addressable::URI.encode_component("foo/bar", Addressable::URI::CharacterClasses::AUTHORITY)'
/Users/dentarg/.gem/ruby/3.0.2/gems/addressable-2.8.0/lib/addressable/uri.rb:412: warning: character class has duplicated range: /[^a-zA-Z0-9\-\.\_\~\!\$\&\'\(\)\*\+\,\;\=\:\@\[\:\]]/

# or

$ irb -w -r addressable/uri
irb(main):001:0> Addressable::VERSION::STRING
=> "2.8.0"
irb(main):002:0> Regexp.compile("[#{Addressable::URI::CharacterClasses::AUTHORITY}]")
(irb):2: warning: character class has duplicated range: /[a-zA-Z0-9\-\.\_\~\!\$\&\'\(\)\*\+\,\;\=\:\@\[\:\]]/
=> /[a-zA-Z0-9\-\.\_\~\!\$\&\'\(\)\*\+\,\;\=\:\@\[\:\]]/

@dentarg
Copy link
Collaborator

dentarg commented Jan 15, 2022

Solved by #438

@dentarg dentarg closed this as completed Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants