From 3782f3ddbf7aa3af50d85bf492fbc4c9be8cdb3c Mon Sep 17 00:00:00 2001 From: Himbeer Date: Mon, 20 Jan 2025 16:02:39 +0100 Subject: Make formspec textureName regexp more restrictive The new regexp only matches the .png, .jpg, .bmp and .tga file extensions (case-insensitive). This prevents a few false replacements, though the ultimate fix should be a proper formspec parser. This commit is a temporary solution to #158. --- formspec.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/formspec.go b/formspec.go index a465143..bfe2e98 100644 --- a/formspec.go +++ b/formspec.go @@ -6,7 +6,7 @@ import ( var itemName = regexp.MustCompile("(item_image\\[[0-9.-]+,[0-9.-]+;[0-9.-]+,[0-9.-]+;)([a-zA-Z0-9-_.: ]+)(\\])") var itemButtonName = regexp.MustCompile("(item_image_button\\[[0-9.-]+,[0-9.-]+;[0-9.-]+,[0-9.-]+;)([a-zA-Z0-9-_.: ]+)(;[a-zA-Z0-9-_.: ]+;[^\\[\\]]*\\])") -var textureName = regexp.MustCompile("([a-zA-Z0-9-_.]+\\.[a-zA-Z-_.]+)") +var textureName = regexp.MustCompile("([a-zA-Z0-9-_.]+\\.(?i:png|jpg|bmp|tga))") func (sc *ServerConn) prependFormspec(fs *string) { *fs = ReplaceAllStringSubmatchFunc(textureName, *fs, func(groups []string) string { -- cgit v1.2.3