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

cssrewrite breaks SVG Data URI #508

Open
robshep opened this issue Aug 3, 2018 · 2 comments
Open

cssrewrite breaks SVG Data URI #508

robshep opened this issue Aug 3, 2018 · 2 comments

Comments

@robshep
Copy link

robshep commented Aug 3, 2018

In the default,and with a replace map config, the cssrewrite filter breaks a data uri css url with SVG content.

This particular breakage affecting me is in the css of Bootstrap 4(.1.3)

https://github.com/twbs/bootstrap/blob/v4.1.3/dist/css/bootstrap.css#L4308

original:

   Original: "data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255, 255, 255, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E"
Replacement: "data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255, 255, 255, 0.5")' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E"
marker.....                                                                                                                                          ^ spurious character

Note:
I've tried to workaround this, but the replace lambda version only gives me the url to fiddle with, and not the original path, so I'm stuck.

@barbossa
Copy link

I confirm the issue. Someone has a solution?

@02JanDal
Copy link

02JanDal commented Jun 1, 2019

Also ran into this, solved it by subclassing CSSRewrite and overriding rewrite_url to just returning the matched data if it seems to be a data-url (which doesn't make sense to rewrite anyway):

def rewrite_url(self, m):
    url = m.groups()[1]
    if url.startswith('data:') or url.startswith('"data:') or url.startswith('\'data:'):
        return m.group(0)
    else:
        return super(FixedCSSRewrite, self).rewrite_url(m)

I can put this into a PR if this is an acceptable solution.

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

3 participants