mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Keep (add if not existing) xmlns attribute for generated SVG images (#23410)
Fix #23409 Developers could browse & preview the local SVG images files directly. It still has clear output.   --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: delvh <leon@kske.dev>
This commit is contained in:
@@ -25,6 +25,12 @@ const defaultSize = 16
|
||||
// Init discovers SVGs and populates the `SVGs` variable
|
||||
func Init() {
|
||||
SVGs = Discover()
|
||||
|
||||
// Remove `xmlns` because inline SVG does not need it
|
||||
r := regexp.MustCompile(`(<svg\b[^>]*?)\s+xmlns="[^"]*"`)
|
||||
for name, svg := range SVGs {
|
||||
SVGs[name] = r.ReplaceAllString(svg, "$1")
|
||||
}
|
||||
}
|
||||
|
||||
// Render render icons - arguments icon name (string), size (int), class (string)
|
||||
|
Reference in New Issue
Block a user