@@ -78,6 +78,10 @@ local function mkdir(path)
78
78
end
79
79
end
80
80
81
+ local function check_filename (name )
82
+ return name :find (" ^[%w%s%^&'@{}%[%],%$=!%-#%(%)%%%.%+~_]+$" ) ~= nil
83
+ end
84
+
81
85
82
86
minetest .register_chatcommand (" /about" , {
83
87
params = " " ,
@@ -885,11 +889,10 @@ minetest.register_chatcommand("/save", {
885
889
worldedit .player_notify (name , " invalid usage: " .. param )
886
890
return
887
891
end
888
- if not param : find ( " ^[a-zA-Z0-9_%-.]+$ " ) then
892
+ if not check_filename ( param ) then
889
893
worldedit .player_notify (name , " Disallowed file name: " .. param )
890
894
return
891
895
end
892
-
893
896
local result , count = worldedit .serialize (worldedit .pos1 [name ],
894
897
worldedit .pos2 [name ])
895
898
@@ -923,8 +926,8 @@ minetest.register_chatcommand("/allocate", {
923
926
worldedit .player_notify (name , " invalid usage: " .. param )
924
927
return
925
928
end
926
- if not string.find (param , " ^[%w \t .,+-_=!@#$%%^&*()%[%]{};' \" ]+$ " ) then
927
- worldedit .player_notify (name , " invalid file name: " .. param )
929
+ if not check_filename (param ) then
930
+ worldedit .player_notify (name , " Disallowed file name: " .. param )
928
931
return
929
932
end
930
933
@@ -1056,7 +1059,7 @@ minetest.register_chatcommand("/mtschemcreate", {
1056
1059
worldedit .player_notify (name , " No filename specified" )
1057
1060
return
1058
1061
end
1059
- if not param : find ( " ^[a-zA-Z0-9_%-.]+$ " ) then
1062
+ if not check_filename ( param ) then
1060
1063
worldedit .player_notify (name , " Disallowed file name: " .. param )
1061
1064
return
1062
1065
end
@@ -1083,10 +1086,14 @@ minetest.register_chatcommand("/mtschemplace", {
1083
1086
description = " Load nodes from \" (world folder)/schems/<file>.mts\" with position 1 of the current WorldEdit region as the origin" ,
1084
1087
privs = {worldedit = true },
1085
1088
func = function (name , param )
1086
- if param == nil then
1089
+ if param == " " then
1087
1090
worldedit .player_notify (name , " no filename specified" )
1088
1091
return
1089
1092
end
1093
+ if not check_filename (param ) then
1094
+ worldedit .player_notify (name , " Disallowed file name: " .. param )
1095
+ return
1096
+ end
1090
1097
1091
1098
local pos = get_position (name )
1092
1099
if pos == nil then return end
0 commit comments