Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

HTML::Document#initialize Node.parse call missing strict argument

#330

While working on a screen-scraping application using scrAPI, I noticed some parser exceptions when using the gem with Rails. With the help of Scott White, we were able to track down the source of the exceptions.

Looking at line 20 of actionpack-2.1.0/lib/action_controller/vendor/html-scanner/html/document.rb you'll notice the following method call:

node = Node.parse(node_stack.last, tokenizer.line, tokenizer.position, token)

I think this method call should actually be..

node = Node.parse(node_stack.last, tokenizer.line, tokenizer.position, token, strict)

The local variable 'strict' is passed in as an argument and defaults to false. Passing this parameter on to the Node.parse call will stop the method from throwing exceptions when bad markup is attempting to parse.

Reported by Jimmy Baker · June 4th, 2008 @ 07:27 PM

State: resolved
Milestone: 2.1.1
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. DHH
    DHH

    Could you post the exceptions you're seeing?

    June 4th, 2008 @ 04:14 PM

  2. Jimmy Baker
    Jimmy Baker

    Certainly. The following pastie shows my code and the exceptions that are produced from it:

    http://pastie.caboo.se/208451

    June 4th, 2008 @ 05:02 PM

  3. jdwyah
    jdwyah

    +1. Google Website Optimizer script tags break my assert_select calls without this.

    June 12th, 2008 @ 06:51 PM

  4. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 2.1.1
    • State changed from new to open
    • Assigned user set to Jeremy Kemper

    June 16th, 2008 @ 12:27 PM

  5. Jeremy Kemper
    Jeremy Kemper
    • State changed from open to incomplete

    The change looks good, but needs test coverage.

    Could you write up a patch with a test case?

    June 23rd, 2008 @ 02:47 AM

  6. Jimmy Baker
    Jimmy Baker

    Absolutely! Stay tuned..

    June 24th, 2008 @ 02:14 AM

  7. Jimmy Baker
    Jimmy Baker

    Patch attached. The patch includes the fix along with two tests.

    June 25th, 2008 @ 06:28 AM

  8. Jeremy Kemper
    Jeremy Kemper
    • State changed from incomplete to open

    Thanks! Want to adjust your email address in your global git config and resubmit before I apply?

    June 25th, 2008 @ 06:40 AM

  9. Jimmy Baker
    Jimmy Baker

    Oops! Thanks for noticing. Email updated. The revised patch is attached.

    June 25th, 2008 @ 06:55 AM

  10. Repository
    Repository
    • State changed from open to resolved

    (from [02ffbc27637db50b7c663d367d0f4712738b0aae]) Patched HTML::Document#initialize call to Node.parse so that it includes the strict argument. [#330 state:resolved]

    http://github.com/rails/rails/co...

    June 25th, 2008 @ 07:14 AM