henrik / validates_url_format_of

Validate the format of a URL by regexp in Ruby on Rails.
101 stars 32 forks source link

Urls with subdomains are treated as invalid #2

Closed kristopher closed 13 years ago

kristopher commented 14 years ago

Loaded suite validates_url_format_of_test Started ..F. Finished in 0.058049 seconds.

1) Failure: test_should_allow_valid_urls(ValidatesUrlFormatOfTest) [validates_url_format_of_test.rb:76]: "http://sub.domain.example.com/" should have been accepted

4 tests, 22 assertions, 1 failures, 0 errors, 0 skips

henrik commented 14 years ago

That's strange. I get 4 tests, 42 assertions, 0 failures, 0 errors. Are you using the latest version (with ec1213abb857f6b4936d18a77e93004c2f37f444as HEAD)?

kristopher commented 14 years ago

Its seems to be a ruby 1.9.1 and 1.9.2 issue, the test pass in 1.8.7

kristopher commented 14 years ago

The tests are also getting this error in 1.9.1 and 1.9.2

validates_url_format_of_test.rb:67: invalid multibyte char (US-ASCII) validates_url_format_of_test.rb:67: invalid multibyte char (US-ASCII) validates_url_format_of_test.rb:67: syntax error, unexpected $end, expecting ']' 'http://räksmörgås.nu', # IDN ^

x37v commented 13 years ago

for ruby 1.9+ you can put

# encoding: utf-8

at the top of the test file to get the test to run [ruby will interpret the file as utf-8]. but I still get errors 1) Failure: test_should_allow_valid_urls(ValidatesUrlFormatOfTest) [validates_url_format_of_test.rb:77]: "http://sub.domain.example.com/" should have been accepted 4 tests, 22 assertions, 1 failures, 0 errors, 0 skips

aselder commented 13 years ago

See my comments to issue #4.

There is a bug in the Ruby 1.9 reg ex engine involving \W and case insensitive flag which causes problems for strings containing 'k' and 's'

henrik commented 13 years ago

Work around Ruby 1.9.2 bug with \W and i flag. Closed by 1c43a0b671696e8460cb5d38430d7c532ea21330. Closed by 1c43a0b671696e8460cb5d38430d7c532ea21330.

Thanks to aselder for pointing it out here: https://github.com/henrik/validates_url_format_of/issues/#issue/4

Ruby ticket here: http://redmine.ruby-lang.org/issues/show/4044