Skip to content

Commit f623c92

Browse files
committed
Change separator in data file
Using '|' as the data separator caused crashes if a path with a '|' char in it was in the data file. Changing that separator to a null byte ensures that this kind of issue can never happen again as the null byte can't be in a path.
1 parent 7f2bfcb commit f623c92

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

z.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Z_MATCHMODE = 0
128128
Z_MATCHNAME = false
129129
Z_SKIPPWD = false
130130
Z_HYPHEN = false
131+
Z_DATA_SEPARATOR = "\0"
131132

132133
os.LOG_NAME = os.getenv('_ZL_LOG_NAME')
133134

@@ -1073,7 +1074,7 @@ function data_load(filename)
10731074
return {}
10741075
end
10751076
for line in fp:lines() do
1076-
local part = string.split(line, '|')
1077+
local part = string.split(line, Z_DATA_SEPARATOR)
10771078
local item = {}
10781079
if part and part[1] and part[2] and part[3] then
10791080
local key = insensitive and part[1]:lower() or part[1]
@@ -1135,7 +1136,7 @@ function data_save(filename, M)
11351136
end
11361137
for i = 1, #M do
11371138
local item = M[i]
1138-
local text = item.name .. '|' .. item.rank .. '|' .. item.time
1139+
local text = item.name .. Z_DATA_SEPARATOR .. item.rank .. Z_DATA_SEPARATOR .. item.time
11391140
fp:write(text .. '\n')
11401141
end
11411142
fp:close()

0 commit comments

Comments
 (0)