Skip to content

Commit

Permalink
Merge pull request #1605 from doorkeeper-gem/fix-uri-valiation-for-ru…
Browse files Browse the repository at this point in the history
…by-3.2

Fix URI validation for Ruby 3.2+
  • Loading branch information
nbulaj authored Dec 1, 2022
2 parents 248af2f + 5f044f6 commit 869410d
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 207 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ User-visible changes worth mentioning.
## main

- [#ID] Add your PR description here.
- [#1605] Fix URI validation for Ruby 3.2+.

## 5.6.2

Expand Down
6 changes: 3 additions & 3 deletions lib/doorkeeper/oauth/helpers/uri_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ def self.query_matches?(query, client_query)
end

def self.valid_scheme?(uri)
return false if uri.scheme.nil?
return false if uri.scheme.blank?

%w[localhost].include?(uri.scheme) == false
%w[localhost].exclude?(uri.scheme)
end

def self.hypertext_scheme?(uri)
%w[http https].include?(uri.scheme)
end

def self.iff_host?(uri)
!(hypertext_scheme?(uri) && uri.host.nil?)
!(hypertext_scheme?(uri) && uri.host.blank?)
end

def self.oob_uri?(uri)
Expand Down
4 changes: 2 additions & 2 deletions lib/doorkeeper/orm/active_record/redirect_uri_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def unspecified_scheme?(uri)
end

def unspecified_host?(uri)
uri.is_a?(URI::HTTP) && uri.host.nil?
uri.is_a?(URI::HTTP) && uri.host.blank?
end

def relative_uri?(uri)
uri.scheme.nil? && uri.host.nil?
uri.scheme.nil? && uri.host.blank?
end

def invalid_ssl_uri?(uri)
Expand Down
Loading

0 comments on commit 869410d

Please sign in to comment.