Skip to content

consume_url does not record newlines #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
haxney opened this issue Oct 31, 2013 · 2 comments
Closed

consume_url does not record newlines #27

haxney opened this issue Oct 31, 2013 · 2 comments

Comments

@haxney
Copy link

haxney commented Oct 31, 2013

In consume_url(), a newline character is consumed without calling
tokenizer.new_line(). This can be fixed by replacing the first match block
of consume_url() with

match tokenizer.current_char() {
    '\t' | ' ' => tokenizer.position += 1,
    '\n' => { tokenizer.position += 1;
                tokenizer.new_line(); },
    "\"" => return consume_quoted_url(tokenizer, false),
    '\'' => return consume_quoted_url(tokenizer, true),
    ')' => { tokenizer.position += 1; break },
    _ => return consume_unquoted_url(tokenizer),
}
@SimonSapin
Copy link
Member

So the parsed tree is correct, except for the line numbers? Could you give an example of CSS that is affected by this?

@haxney
Copy link
Author

haxney commented Oct 31, 2013

The problem is when there is a newline in the url() token, as in the following
file:

a {
  url(
  http://example.com
  );
  clear:left;
}

The following test fails with 'The tokenizer is missing a tokenizer.new_line() call somewhere.', tokenizer.rs:104

#[test]
fn url_newline() {
    let thing = tokenize("a {\n  url(\nhttp://example.com\n);\n  clear:left;\n}").to_owned_vec();
    println(list_to_json(&thing).to_str());
}

kmcallister added a commit that referenced this issue Nov 6, 2013
Fix #27: line number tracking inside url()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants