aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2025-01-20 16:02:39 +0100
committerHimbeer <himbeer@disroot.org>2025-01-20 16:02:39 +0100
commit3782f3ddbf7aa3af50d85bf492fbc4c9be8cdb3c (patch)
tree7d5c410d332a76a09cbde8bac35e88edfc7779b0
parent256451962f7cbdba5818ee093645a29e9882b5bd (diff)
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.
-rw-r--r--formspec.go2
1 files changed, 1 insertions, 1 deletions
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 {