From 5801030e318e8182c4f6e992e15a94e53e043c5c Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 8 Jul 2017 11:50:21 +1200 Subject: [PATCH] fix id collisions causing truncated shield svgs --- lib/util.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/util.php b/lib/util.php index 8204994..5f274c0 100644 --- a/lib/util.php +++ b/lib/util.php @@ -15,6 +15,12 @@ function mkshield($left_str, $right_str, $color_str) { } else { $retn = file_get_contents('https://img.shields.io/badge/'.$filename); + + // We need unique IDs + $prefix = substr(sha1($filename), 8).'-'; + $retn = str_replace('id="', 'id="'.$prefix, $retn); + $retn = str_replace('url(#', 'url(#'.$prefix, $retn); + file_put_contents($cache_path, $retn); return $retn;