Skip to content
Browse files

Fixed bug in URI validation when authority contains a port number.

  • Loading branch information...
1 parent 8671f54 commit 9ebede6b36b856b5be4e41d9f0a4d175428207aa @gkellogg gkellogg committed
Showing with 11 additions and 6 deletions.
  1. +1 −1 lib/rdf/model/uri.rb
  2. +10 −5 spec/model_uri_spec.rb
View
2 lib/rdf/model/uri.rb
@@ -82,7 +82,7 @@ class URI
IREG_NAME = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS}))*")
IHOST = Regexp.compile("(?:#{IP_literal})|(?:#{IREG_NAME})")
IUSERINFO = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS})|:)*")
- IAUTHORITY = Regexp.compile("(?:#{IUSERINFO}@)?#{IHOST}(?:#{PORT})?")
+ IAUTHORITY = Regexp.compile("(?:#{IUSERINFO}@)?#{IHOST}(?::#{PORT})?")
IRELATIVE_PART = Regexp.compile("(?:(?://#{IAUTHORITY}(?:#{IPATH_ABEMPTY}))|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_NOSCHEME})|(?:#{IPATH_EMPTY}))")
IRELATIVE_REF = Regexp.compile("^#{IRELATIVE_PART}(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$")
View
15 spec/model_uri_spec.rb
@@ -86,14 +86,14 @@
"and fragment" => "%s#%s",
"and query and fragment" => "%s?%s#%s",
}.each do |mod, fmt|
- it "validates IRI with authority and abempty #{mod}" do
+ it "validates IRI with authority and ipath-abempty #{mod}" do
refs.each do |c|
- RDF::URI("scheme:auth//#{fmt}" % ["", c, c]).should be_valid
- RDF::URI("scheme:auth//#{fmt}" % [c, c, c]).should be_valid
- RDF::URI("scheme:auth//#{fmt}" % ["#{c}/#{c}", c, c]).should be_valid
+ RDF::URI("scheme://auth/#{fmt}" % ["", c, c]).should be_valid
+ RDF::URI("scheme://auth/#{fmt}" % [c, c, c]).should be_valid
+ RDF::URI("scheme://auth/#{fmt}" % ["#{c}/#{c}", c, c]).should be_valid
end
end
- it "validates IRI with ipath-absolute #{mod}" do
+ it "validates IRI with path-absolute #{mod}" do
refs.each do |c|
RDF::URI("scheme:/#{fmt}" % ["", c, c]).should be_valid
RDF::URI("scheme:/#{fmt}" % [c, c, c]).should be_valid
@@ -117,6 +117,11 @@
RDF::URI("//auth/#{fmt}" % [c, c, c]).should be_valid
end
end
+ it "validates irelative-ref with authority and port #{mod}" do
+ refs.each do |c|
+ RDF::URI("//auth:123/#{fmt}" % [c, c, c]).should be_valid
+ end
+ end
it "validates irelative-ref with ipath-absolute #{mod}" do
refs.each do |c|
RDF::URI("/#{fmt}" % [c, c, c]).should be_valid

0 comments on commit 9ebede6

Please sign in to comment.
Something went wrong with that request. Please try again.