SVG in articles?
-
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.
Hah! No I did not. Excellent suggestion, thanks.
-
Yes, it does have that potential. No chance of applying a sanitizer perhaps? https://github.com/alister-/SVG-Sanitizer for example? Thanks for listening :)
-
Yes, it does have that potential. No chance of applying a sanitizer perhaps? https://github.com/alister-/SVG-Sanitizer for example? Thanks for listening :)
Spend the 30 mins converting that to C# for me and yep, I'll do it.
cheers Chris Maunder
-
Spend the 30 mins converting that to C# for me and yep, I'll do it.
cheers Chris Maunder
It's a deal. I'll ping you here when it's ready :)
-
Spend the 30 mins converting that to C# for me and yep, I'll do it.
cheers Chris Maunder
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 -
It's a deal. I'll ping you here when it's ready :)
-
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 -
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).
SVG support has been added.
cheers Chris Maunder
-
SVG support has been added.
cheers Chris Maunder
Now that IS agile.
-
SVG support has been added.
cheers Chris Maunder
: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