w3c-validators/w3c_validators

Internal server error on validating CSS

Closed this issue · 8 comments

I cannot validate any CSS. The following code:

require 'w3c_validators'

include W3CValidators

@validator = CSSValidator.new

results = @validator.validate_uri('http://www.csszengarden.com/examples/style.css')

if results.errors.length > 0
    results.errors.each do |err|
          puts err.to_s
            end
else
    puts 'Valid!'
end

results in the following error:

/Users/me/.rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http/response.rb:120:in `error!': 500"Internal Server Error" (Net::HTTPFatalError)
        from /Users/me/.rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http/response.rb:129:in `value'
        from /Users/me/.gem/ruby/2.3.1/gems/w3c_validators-1.2/lib/w3c_validators/validator.rb:88:in `send_request'
        from /Users/me/.gem/ruby/2.3.1/gems/w3c_validators-1.2/lib/w3c_validators/css_validator.rb:87:in `validate'
        from /Users/me/.gem/ruby/2.3.1/gems/w3c_validators-1.2/lib/w3c_validators/css_validator.rb:58:in `validate_uri'
        from validate.rb:7:in `<main>'
doc75 commented

Are you using a published gem (which version) or are you using the master branch ?
Indeed, the master branch has been recently updated but not yet pushed to rubygems.org

I'm using v1.2.

doc75 commented

If you can test current master to see if it solves the issue.
Otherwise, I'll try to publish a new version soon

I've tried to install the current master, but when I require the gem I get uninitialized constant W3CValidators::Validator::VERSION.

Do I need to do anything else, apart from

gem build w3c_validators.gemspec
gem install ./w3c_validators-1.2.gem

?

doc75 commented

I just merged PR #22 to fix this error.
Could you give it another try ?

Ok, so the master works better (I'm using it through Nanoc: v1.2 was raising an error when validating a CSS file, but now it works), but the example above still fails with the same error. Can't you reproduce it?

doc75 commented

Yes, I can reproduce the issue.
INdeed, when trying to test the CSS file directly on the w3c site we get this message:

Validator
Error
Target: http://www.csszengarden.com/examples/style.css

I/O Error: Unknown mime type : application/octet-stream

My best guess is that csszengardent does not return the correct mime type for this css file.

This seems to be confirmed on my side by the fact that entering the css URL in my browser, the browser propose to download it rather than displaying its content. I have tries with other site and css is displayed, not downloaded.

Ah, you are right. I have chosen the CSS badly, because that is not the site's CSS, but a download. If I test against the site's stylesheet, it works. Thanks!