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

Replace base64 with plain body #577

Closed
thekondrashov opened this issue Nov 28, 2015 · 9 comments
Closed

Replace base64 with plain body #577

thekondrashov opened this issue Nov 28, 2015 · 9 comments

Comments

@thekondrashov
Copy link
Contributor

At the moment, badges with icons such as these:
GitHub forks Twitter URL
… contain svg-logos in the base64-coded form in the attribute of <image /> tag:

<svg xmlns="...">
  <!-- some code -->
  <image xlink:href="data:image/svg+xml;base64,HUGE+DATA"/>
  <!-- some code -->
</svg>

But it is possible to embed one svg-image into another svg-image as plain body. For example:

<svg xmlns="...">
  <!-- some code -->
  <svg><!-- plain body of injected svg --></svg>
  <!-- some code -->
</svg>

Test it with the example in the wild: https://commons.wikimedia.org/wiki/File:English_language.svg
In this case, child svg inherits properties of parent svg, but you can override them:

<!-- now -->
<image x="5" y="3" width="14" height="14" xlink:href="data:image/svg+xml;base64,HUGE+DATA"/>
<!-- will be -->
<svg x="5" y="3" width="14" height="14" viewBox="..."><!-- plain body --></svg>

You even can remove xmlns="http://www.w3.org/2000/svg" attribute from child svg!
Using this tip you can replace the huge base64 code with simple, short and readable plain code.
But of course, it breaks the current algorithm for generating the badges. What do you think?

@espadrine
Copy link
Member

That's a very interesting option! We could special-case data:image/svg+xml to include the SVG inline.

@levithomason
Copy link

bump

@techtonik
Copy link
Contributor

@espadrine
Copy link
Member

Should I consider this bug fixed, @thekondrashov?

@paulmelnikow
Copy link
Member

Feel free to reopen if you'd like to discuss further.

@MetalArend
Copy link

The image as mentioned by techtonik is not working, neither in chrome nor in safari. It shows an error error on line 1 at column 652: Unescaped '<' not allowed in attributes values. Is this a known issue, or was it introduced by a certain change?

@techtonik
Copy link
Contributor

@MetalArend yes, it became broken after some Chrome version (or maybe GitHub?). See #507 (comment) for fixed examples.

@MetalArend
Copy link

Cool, thanks! :)

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

6 participants