mirror of
https://github.com/MvDevsUnion/WPetition.git
synced 2026-08-01 12:14:48 +00:00
fixed svg validation
added debug endpoint to test svg errors
This commit is contained in:
@@ -273,6 +273,17 @@ namespace Submission.Api.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("svg-debug", Name = "SvgDebug")]
|
||||||
|
public async Task<IActionResult> SVG_TEST([FromForm]string svg)
|
||||||
|
{
|
||||||
|
// SVG validation: reject bad/malicious SVGs before persisting
|
||||||
|
if (!Submission.Api.Services.SvgValidator.TryValidate(svg, out var svgError))
|
||||||
|
{
|
||||||
|
return BadRequest($"Invalid signature SVG: {svgError}");
|
||||||
|
}
|
||||||
|
return Ok("Valid SVG");
|
||||||
|
}
|
||||||
|
|
||||||
private (string frontmatter, string body) ParseMarkdownFile(string content)
|
private (string frontmatter, string body) ParseMarkdownFile(string content)
|
||||||
{
|
{
|
||||||
var lines = content.Split('\n');
|
var lines = content.Split('\n');
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Submission.Api.Services
|
|||||||
// Basic attribute whitelist (prefix-free) - attributes not listed are still allowed but checked for danger.
|
// Basic attribute whitelist (prefix-free) - attributes not listed are still allowed but checked for danger.
|
||||||
private static readonly HashSet<string> AllowedAttributes = new(StringComparer.OrdinalIgnoreCase)
|
private static readonly HashSet<string> AllowedAttributes = new(StringComparer.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
"id","class","width","height","viewBox","fill","stroke","d","x","y","cx","cy","r","rx","ry","points",
|
"id","class","width","height","viewBox","fill","stroke","d","x","y","cx","cy","r","rx","ry","points","stroke-linecap","stroke-linejoin",
|
||||||
"transform","style","xmlns","xmlns:xlink","xlink:href","href","opacity","stroke-width","font-size","font-family"
|
"transform","style","xmlns","xmlns:xlink","xlink:href","href","opacity","stroke-width","font-size","font-family"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user