viewport-units-buggyfill
viewport-units-buggyfill copied to clipboard
viewportUnitExpression is matching base64 strings
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
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;
which is the best option to use here? As I have the same issue.
The best option would be to test @badsyntax's change and send a PR for it :)
@rodneyrehm #86 can you please review?