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

Bug: SVG size #64

Open
tuncbkose opened this issue Jun 6, 2024 · 0 comments
Open

Bug: SVG size #64

tuncbkose opened this issue Jun 6, 2024 · 0 comments

Comments

@tuncbkose
Copy link

Hi, I just noticed that some of my svg files, obtained for example from dvisvgm, specify their size with width='{number}pt' and height='{number}pt'. For these files, the regex in

# handle SVGs
elif size >= 5 and (head.startswith(b'<?xml') or head.startswith(b'<svg')):
fhandle.seek(0)
data = fhandle.read(1024)
try:
data = data.decode('utf-8')
width = re.search(r'[^-]width="(.*?)"', data).group(1)
height = re.search(r'[^-]height="(.*?)"', data).group(1)
except Exception:
raise ValueError("Invalid SVG file")
width = _convertToPx(width)
height = _convertToPx(height)
doesn't match due to the different quotation marks.

I imagine one can naively change the regex to have something like ["|'], but then you would be matching incorrect strings like "wrong'. I'm sure this is a solved problem that is beyond my regex knowledge, but it would be nice for this to be fixed.

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

No branches or pull requests

1 participant