Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Site Bugs / Suggestions
  4. SVG in articles?

SVG in articles?

Scheduled Pinned Locked Moved Site Bugs / Suggestions
questiongraphicslounge
13 Posts 6 Posters 16 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Jerry Evans

    Hello CP It would be great to be able to upload and link to SVG files for decent vector imaging. I recently tried adding some SVG UML diagrams to an article but had to drop back to making (highly unsatisfactory) JPEGs first. TIA! Jerry P.S A slightly more general question was asked some time back but the SVG aspect remains unanswered ('09 actually).

    C Offline
    C Offline
    Chris Maunder
    wrote on last edited by
    #3

    SVG is a leaky boat so unfortunately we can't allow SVG uploads. Take a look at this[^]

    cheers Chris Maunder

    J 1 Reply Last reply
    0
    • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

      Did you tried to include your SVG inside the HTML of your article? It works perfectly as I can see...

      Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.

      J Offline
      J Offline
      Jerry Evans
      wrote on last edited by
      #4

      Hah! No I did not. Excellent suggestion, thanks.

      1 Reply Last reply
      0
      • C Chris Maunder

        SVG is a leaky boat so unfortunately we can't allow SVG uploads. Take a look at this[^]

        cheers Chris Maunder

        J Offline
        J Offline
        Jerry Evans
        wrote on last edited by
        #5

        Yes, it does have that potential. No chance of applying a sanitizer perhaps? https://github.com/alister-/SVG-Sanitizer for example? Thanks for listening :)

        C 1 Reply Last reply
        0
        • J Jerry Evans

          Yes, it does have that potential. No chance of applying a sanitizer perhaps? https://github.com/alister-/SVG-Sanitizer for example? Thanks for listening :)

          C Offline
          C Offline
          Chris Maunder
          wrote on last edited by
          #6

          Spend the 30 mins converting that to C# for me and yep, I'll do it.

          cheers Chris Maunder

          J 2 Replies Last reply
          0
          • C Chris Maunder

            Spend the 30 mins converting that to C# for me and yep, I'll do it.

            cheers Chris Maunder

            J Offline
            J Offline
            Jerry Evans
            wrote on last edited by
            #7

            It's a deal. I'll ping you here when it's ready :)

            F 1 Reply Last reply
            0
            • C Chris Maunder

              Spend the 30 mins converting that to C# for me and yep, I'll do it.

              cheers Chris Maunder

              J Offline
              J Offline
              Jerry Evans
              wrote on last edited by
              #8

              Yo. Here it is.

              /*

              A really simple SVG cleaner for the CodeProject
              
              This is a \*big\* thanks to Chris Maunder and the team for their great work 
              
                  Based on an original PHP implementation here:
              
                  https://github.com/alister-/SVG-Sanitizer
              
              Copyright (c) Jerry Evans, 2015
              All rights reserved.
              
              The MIT License (MIT)
              
              Copyright (c) 2015 Jerry Evans
              
              Permission is hereby granted, free of charge, to any person obtaining a copy
              of this software and associated documentation files (the "Software"), to deal
              in the Software without restriction, including without limitation the rights
              to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
              copies of the Software, and to permit persons to whom the Software is
              furnished to do so, subject to the following conditions:
              
              The above copyright notice and this permission notice shall be included in
              all copies or substantial portions of the Software.
              
              THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
              IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
              FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
              AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
              LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
              OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
              THE SOFTWARE.
              

              */

              using System;
              using System.Collections.Generic;
              using System.Linq;
              using System.Text;
              using System.Xml;

              namespace svgcheck
              {
              class SVGChecker
              {
              /// /// dictionary of string to hashset maps valid SVG tags to valid attributes. All else is discarded (!)
              ///
              static Dictionary> dict = new Dictionary>()
              {
              { "a", new HashSet{"class", "clip-path", "clip-rule", "fill", "fill-opacity", "fill-rule", "filter", "id", "mask", "opacity", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "style", "systemLanguage", "transform", "href", "xlink:href", "xlink:title"} },
              { "circle", new HashSet{"class", "clip-path", "clip-rule", "cx", "cy", "fill", "fill-opacity", "fill-rule", "filter", "id", "mask", "opacity", "r", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit

              F 1 Reply Last reply
              0
              • J Jerry Evans

                It's a deal. I'll ping you here when it's ready :)

                F Offline
                F Offline
                Forogar
                wrote on last edited by
                #9

                I'll help, if you need any. SVG is fun and now supported in all major browsers! Yeah!

                - I would love to change the world, but they won’t give me the source code.

                1 Reply Last reply
                0
                • J Jerry Evans

                  Yo. Here it is.

                  /*

                  A really simple SVG cleaner for the CodeProject
                  
                  This is a \*big\* thanks to Chris Maunder and the team for their great work 
                  
                      Based on an original PHP implementation here:
                  
                      https://github.com/alister-/SVG-Sanitizer
                  
                  Copyright (c) Jerry Evans, 2015
                  All rights reserved.
                  
                  The MIT License (MIT)
                  
                  Copyright (c) 2015 Jerry Evans
                  
                  Permission is hereby granted, free of charge, to any person obtaining a copy
                  of this software and associated documentation files (the "Software"), to deal
                  in the Software without restriction, including without limitation the rights
                  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
                  copies of the Software, and to permit persons to whom the Software is
                  furnished to do so, subject to the following conditions:
                  
                  The above copyright notice and this permission notice shall be included in
                  all copies or substantial portions of the Software.
                  
                  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
                  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
                  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
                  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
                  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
                  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
                  THE SOFTWARE.
                  

                  */

                  using System;
                  using System.Collections.Generic;
                  using System.Linq;
                  using System.Text;
                  using System.Xml;

                  namespace svgcheck
                  {
                  class SVGChecker
                  {
                  /// /// dictionary of string to hashset maps valid SVG tags to valid attributes. All else is discarded (!)
                  ///
                  static Dictionary> dict = new Dictionary>()
                  {
                  { "a", new HashSet{"class", "clip-path", "clip-rule", "fill", "fill-opacity", "fill-rule", "filter", "id", "mask", "opacity", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "style", "systemLanguage", "transform", "href", "xlink:href", "xlink:title"} },
                  { "circle", new HashSet{"class", "clip-path", "clip-rule", "cx", "cy", "fill", "fill-opacity", "fill-rule", "filter", "id", "mask", "opacity", "r", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit

                  F Offline
                  F Offline
                  Forogar
                  wrote on last edited by
                  #10

                  Excellent work! :-D

                  - I would love to change the world, but they won’t give me the source code.

                  1 Reply Last reply
                  0
                  • J Jerry Evans

                    Hello CP It would be great to be able to upload and link to SVG files for decent vector imaging. I recently tried adding some SVG UML diagrams to an article but had to drop back to making (highly unsatisfactory) JPEGs first. TIA! Jerry P.S A slightly more general question was asked some time back but the SVG aspect remains unanswered ('09 actually).

                    C Offline
                    C Offline
                    Chris Maunder
                    wrote on last edited by
                    #11

                    SVG support has been added.

                    cheers Chris Maunder

                    P S 2 Replies Last reply
                    0
                    • C Chris Maunder

                      SVG support has been added.

                      cheers Chris Maunder

                      P Offline
                      P Offline
                      Pete OHanlon
                      wrote on last edited by
                      #12

                      Now that IS agile.

                      1 Reply Last reply
                      0
                      • C Chris Maunder

                        SVG support has been added.

                        cheers Chris Maunder

                        S Offline
                        S Offline
                        SoMad
                        wrote on last edited by
                        #13

                        :thumbsup: That is awesome! Since I know it is possible to do inline SVGs (at least in QA answers), you should probably make sure your new sanitizer handles that as well. Last year I answered a question in QA where I fiddled with inline SVG. I got it to display the image, but once I tried modifying my answer, the HTML control would HTML encode the embedded image tag so it wouldn't display. I figured it was some sort of precautionary measure you guys had implemented. Raster to Vector Image without autotrace - Solution 3[^] Here is another answer where I added an inline SVG: SVG 2 PDF conversion in python using the svglib package does not work on my svg file - Solution 1[^] Soren Madsen

                        "When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups