Skip Navigation

today i learned: svg files are just text in an html-like language

what the heck!! that is so wild, mind blowing, i thought the main difference between raster graphics and vector graphics was the quality but i didn't think about it too deeply.

i had no idea svg files actually used html code and pretty much could be modified using only text and amazing code woa!!! this opens up the possibility for so many things on linux i think.

for example, on a linux distro, we could modify the desktop environment and make it waaaaay lighter by getting rid of jpg or png icons and just using pure svg on it.

svg can be given a lot of attributes like movement, mouse hovering, change color, change anything. and most svg files are still under a megabyte. wow.. please let me know other fun facts about svg or eps files. i really like doing graphic design on linux and inkscape.

51 comments
  • They can include runnable JavaScript too, which can cause vulnerabilities in certain contexts. One example from work some years back: We had a web app where users could upload files, and certain users could view files uploaded by others. They had the option to download the file or, if it was a file type that the browser could display (like an image or a PDF), the site would display it directly on the page.

    To prevent any XSS (scripts from user-provided files), we served all files with the CSP sandbox header, which prevents any scripts from running. However, at the time, that header broke some features of the video player on certain browsers (I think in Safari, at least), so we had to serve some file types without the header. Mistakenly, we also included image files in the exclusion, as everyone through image files couldn't contain scripts. But the MIME type for SVG files is image/svg+xml... It was very embarrassing to have such a simple XSS vuln flagged in a security audit.

  • we could modify the desktop environment and make it waaaaay lighter by getting rid of jpg or png icons and just using pure svg on it

    That's already happening.

    You can also change the main color of many SVGs (icons or even desktop backgrounds) with one simple edit, one command, one click.

    In web sites, you can assign CSS classes to SVG graphics and thus e.g. change their color according to a theme.

    That's my extent of fiddling with it.

    IIRC they also use fonts the same way CSS/HTML does.

    BTW, there are situations where an SVG is significantly larger than a corresponding raster image. It depends on the content.

51 comments