Skip to content

Commit

Permalink
Add sound flag checking to soundExists
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrb93 authored Sep 6, 2024
1 parent 5c5f3dd commit c78c66c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lua/wire/server/wirelib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1537,9 +1537,20 @@ if not WireLib.PatchedDuplicator then
end

function WireLib.SoundExists(path)
path = string.GetNormalizedFilepath(string.gsub(string.sub(path, 1, 260), '["?]', ''))
-- Limit length and remove invalid chars
if #path>260 then path = string.sub(path, 1, 260) end
path = string.gsub(path, "[\"?']", "")

-- Extract sound flags. Only allowed flags are '<', '>', '^', ')'
local flags
flags, path = string.match(path, "^([<>%^%)]*)(.*)")
if #flags==0 or #flags>2 then
flags = nil
end

path = string.GetNormalizedFilepath(path)
if istable(sound.GetProperties(path)) or file.Exists("sound/" .. path, "GAME") then
return path
return flags and (flags..path) or path
end
end

Expand Down

0 comments on commit c78c66c

Please sign in to comment.