viewport-units-buggyfill icon indicating copy to clipboard operation
viewport-units-buggyfill copied to clipboard

viewportUnitExpression is matching base64 strings

Open badsyntax opened this issue 10 years ago • 4 comments

See: https://github.com/rodneyrehm/viewport-units-buggyfill/blob/0c5f0776f23141ae57b78f863dec87179c3a5781/viewport-units-buggyfill.js#L28

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

badsyntax avatar Jan 08 '15 12:01 badsyntax

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 avatar Jan 08 '15 12:01 rodneyrehm

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

bluntspoon avatar Sep 01 '16 15:09 bluntspoon

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

rodneyrehm avatar Sep 01 '16 17:09 rodneyrehm

@rodneyrehm #86 can you please review?

OleksiiKukuruza avatar Sep 25 '17 08:09 OleksiiKukuruza