From d54e3106a934c10d5b9caf1a6fc410e7d9c6d563 Mon Sep 17 00:00:00 2001 From: Logan Shire Date: Mon, 24 Apr 2023 12:20:11 -0400 Subject: [PATCH] Sanitize vips version string (#354) --- vips/image_golden_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vips/image_golden_test.go b/vips/image_golden_test.go index 200cfd4a..9f88c196 100644 --- a/vips/image_golden_test.go +++ b/vips/image_golden_test.go @@ -1035,27 +1035,28 @@ func goldenCreateTest( } func getEnvironment() string { + sanitizedVersion := strings.ReplaceAll(Version, ":", "-") switch runtime.GOOS { case "windows": // Missing Windows version detection. Windows is not a supported CI target right now - return "windows_" + runtime.GOARCH + "_libvips-" + Version + return "windows_" + runtime.GOARCH + "_libvips-" + sanitizedVersion case "darwin": out, err := exec.Command("sw_vers", "-productVersion").Output() if err != nil { - return "macos-unknown_" + runtime.GOARCH + "_libvips-" + Version + return "macos-unknown_" + runtime.GOARCH + "_libvips-" + sanitizedVersion } majorVersion := strings.Split(strings.TrimSpace(string(out)), ".")[0] - return "macos-" + majorVersion + "_" + runtime.GOARCH + "_libvips-" + Version + return "macos-" + majorVersion + "_" + runtime.GOARCH + "_libvips-" + sanitizedVersion case "linux": out, err := exec.Command("lsb_release", "-cs").Output() if err != nil { return "linux-unknown_" + runtime.GOARCH } strout := strings.TrimSuffix(string(out), "\n") - return "linux-" + strout + "_" + runtime.GOARCH + "_libvips-" + Version + return "linux-" + strout + "_" + runtime.GOARCH + "_libvips-" + sanitizedVersion } // default to unknown assets otherwise - return "unknown_" + runtime.GOARCH + "_libvips-" + Version + return "unknown_" + runtime.GOARCH + "_libvips-" + sanitizedVersion } func assertGoldenMatch(t *testing.T, file string, buf []byte, format ImageType) {