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

Already on GitHub? Sign in to your account

Fix parsing of url values with quotes. #9

merged 1 commit into from Feb 29, 2012


None yet
2 participants

YSLOW.peeler.findImportedStyleSheets returns components with URL values still containing ending quotes causing YQL request to fail.

Test case:
Use the bookmarklet in Mozilla Firefox 10 (Mac OS X Lion) on https://developer.mozilla.org/
Run the test. Test fails because of URLs containing ending quotes for fonts.

Chris Chua Fix parsing of url values with quotes.
Ensure that the greedy group does not capture the ending quote by negating the quote characters.

I've looked at issue #7 and the regular expression used: /\burl\((\'|\"|)([^\'\"]+?)\1\)/
I decided that a lazy quantifier isn't required here since that would add an additional check (to fit in that last back referenced group \1) at every point of expanding the group. Since the characters are already negated, greedily matching is fine.
Also, while using a back reference is elegant but since we're not worried about correctness (unless we are...) of the text, matching and negating both types of quotes (or none at all) should do fine.

@marcelduran marcelduran merged commit 70253f2 into marcelduran:master Feb 29, 2012


marcelduran commented Feb 29, 2012

Thanks for the catch and fix @chrisirhc. I've just uploaded bookmarklet version 3.1.0 to our servers, please allow 24 hours to get the previous version fully expired. Feel free to improve the regexp at issue #7 and send me a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment