tenderlove/nokogiri — Issue #581: unexpected '$' after 'CHILD_SELECTOR'
Author: pboling
Created: 2011-12-09 21:05:59+00:00
State: open

## Error

```unexpected '$' after 'CHILD_SELECTOR
'```

## Trigger

Using [CSS3 Substring Matching Attribute Selectors](http://www.456bereastreet.com/archive/200601/css_3_selectors_explained/) in our CSS causes Nokogiri to be unable to parse.

## Environment

$ nokogiri -v
# Nokogiri (1.5.0)
---
warnings: []

nokogiri: 1.5.0
ruby:
version: 1.9.2
platform: x86_64-linux
description: ruby 1.9.2p136 (2010-12-25) [x86_64-linux]
engine: ruby
libxml:
binding: extension
compiled: 2.6.26
loaded: 2.6.26

## Relevant backtrace:

```
/bb/wealth/3ps/ruby-gems/gems/nokogiri-1.5.0/lib/nokogiri/css/parser_extras.rb:87:in `on_error'
/bb/web/ruby-1.9.2/lib/ruby/1.9.1/racc/parser.rb:99:in `_racc_do_parse_c'
/bb/web/ruby-1.9.2/lib/ruby/1.9.1/racc/parser.rb:99:in `do_parse'
/bb/wealth/3ps/ruby-gems/gems/nokogiri-1.5.0/lib/nokogiri/css/parser_extras.rb:62:in `parse'
/bb/wealth/3ps/ruby-gems/gems/nokogiri-1.5.0/lib/nokogiri/css/parser_extras.rb:79:in `xpath_for'
/bb/wealth/3ps/ruby-gems/gems/nokogiri-1.5.0/lib/nokogiri/css.rb:23:in `xpath_for'
/bb/wealth/3ps/ruby-gems/gems/nokogiri-1.5.0/lib/nokogiri/xml/node.rb:106:in `block in search'
/bb/wealth/3ps/ruby-gems/gems/nokogiri-1.5.0/lib/nokogiri/xml/node.rb:104:in `map'
/bb/wealth/3ps/ruby-gems/gems/nokogiri-1.5.0/lib/nokogiri/xml/node.rb:104:in `search'
```

## Example

```
irb(main):001:0> require 'nokogiri'
=> true
irb(main):002:0> css = File.read('example.css')
=> "#flash_container .flash span.error-icon[class$=\"-icon\"] {\n background-position: -110px -34px;\n}\n"
irb(main):003:0> Nokogiri::CSS.parse(css)
Nokogiri::CSS::SyntaxError: unexpected '{' after 'DESCENDANT_SELECTOR'
from /bb/wealth/3ps/ruby-gems/gems/nokogiri-1.5.0/lib/nokogiri/css/parser_extras.rb:87:in `on_error'
from /bb/web/ruby-1.9.2/lib/ruby/1.9.1/racc/parser.rb:99:in `_racc_do_parse_c'
from /bb/web/ruby-1.9.2/lib/ruby/1.9.1/racc/parser.rb:99:in `do_parse'
from /bb/wealth/3ps/ruby-gems/gems/nokogiri-1.5.0/lib/nokogiri/css/parser_extras.rb:62:in `parse'
from /bb/wealth/3ps/ruby-gems/gems/nokogiri-1.5.0/lib/nokogiri/css.rb:17:in `parse'
```

Interestingly when I use that should example CSS the error I get is different than when it parses the whole site master CSS file, though I think they are indicative of the same problem: Nokogiri doesn't currently support CSS3 Substring Matching Attribute Selectors.