Skip to content
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

viewportUnitExpression is matching base64 strings #34

Open
badsyntax opened this issue Jan 8, 2015 · 4 comments
Open

viewportUnitExpression is matching base64 strings #34

badsyntax opened this issue Jan 8, 2015 · 4 comments
Labels

Comments

@badsyntax
Copy link

See:

var viewportUnitExpression = /([+-]?[0-9.]+)(vh|vw|vmin|vmax)/g;

This expression need to be stricter to prevent matching characters within a base64 encoded string. This issue was identified in our application, where this buggyfill script was "corrupting" base64 encoded images.

I wonder if simply adding word boundary metacharacters around the expression will suffice, but as this repository does not contain any sort of automated testing tools, I cannot be sure, and I don't really have the time to manually test this change.

Here's the change: https://gist.github.com/badsyntax/bc4423dc51b04f54ae52/revisions

@rodneyrehm
Copy link
Owner

I'm not sure about the leading word-boundary:

// original
var viewportUnitExpression = /([+-]?[0-9.]+)(vh|vw|vmin|vmax)/g;
// yours
var viewportUnitExpression = /\b([+-]?[0-9.]+)(vh|vw|vmin|vmax)\b/g;
// considering that - and + match \b anyways
var viewportUnitExpression = /((+|-|\b)[0-9.]+)(vh|vw|vmin|vmax)\b/g;

@rodneyrehm rodneyrehm added the bug label Jan 8, 2015
@bluntspoon
Copy link

which is the best option to use here? As I have the same issue.

@rodneyrehm
Copy link
Owner

The best option would be to test @badsyntax's change and send a PR for it :)

@OleksiiKukuruza
Copy link

OleksiiKukuruza commented Sep 25, 2017

@rodneyrehm #86 can you please review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants