Skip to content
Browse files

Enable URI validation checking, except for Unicode values.

  • Loading branch information...
1 parent 64b039b commit 864cb94867fc8b1640dbd0ee6c895a668bec039e @gkellogg gkellogg committed Nov 6, 2012
Showing with 9 additions and 9 deletions.
  1. +1 −5 lib/rdf/model/uri.rb
  2. +8 −4 spec/model_uri_spec.rb
View
6 lib/rdf/model/uri.rb
@@ -214,11 +214,7 @@ def length
def valid?
# As Addressable::URI does not perform adequate validation, validate
# relative to RFC3987
- if RUBY_VERSION >= '1.9'
- to_s.match(RDF::URI::IRI) || to_s.match(RDF::URI::IRELATIVE_REF) || false
- else
- true
- end
+ to_s.match(RDF::URI::IRI) || to_s.match(RDF::URI::IRELATIVE_REF) || false
end
##
View
12 spec/model_uri_spec.rb
@@ -77,10 +77,8 @@
describe "#valid?" do
let(:refs) {
- %W(
- a d z A D Z 0 5 99 - . _ ~ \u0053 \u00D6 \U00000053
- foo Dürst %20
- )
+ %W(a d z A D Z 0 5 99 - . _ ~ \u0053 \u00D6 foo %20) +
+ (RUBY_VERSION >= "1.9" ? %W(\U00000053 Dürst) : [])
}
{
"" => "%s",
@@ -139,6 +137,12 @@
end
end
end
+
+ [" ", "<", ">", "'" '"'].each do |c|
+ it "does not validate <http://example/#{c}>" do
+ RDF::URI("http://example/#{c}").should_not be_valid
+ end
+ end
end
describe "#invalid?" do

0 comments on commit 864cb94

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