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

svg: use higher specifity regexp for checks #128

Merged
merged 6 commits into from Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/types/svg.js
@@ -1,12 +1,12 @@
'use strict';

var svgReg = /<svg[^>]+[^>]*>/;
var svgReg = /<svg\s([^>"']|"[^"]*"|'[^']*')*>/;
function isSVG (buffer) {
return svgReg.test(buffer);
}

var extractorRegExps = {
'root': /<svg\s[^>]+>/,
'root': svgReg,
'width': /\bwidth=(['"])([^%]+?)\1/,
'height': /\bheight=(['"])([^%]+?)\1/,
'viewbox': /\bviewBox=(['"])(.+?)\1/
Expand Down
6 changes: 6 additions & 0 deletions specs/images/invalid/broken-quotes.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions specs/images/invalid/no-quotes.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions specs/images/valid/svg/viewbox-width-height-brackets.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.