Skip to content

Commit

Permalink
Fix regex api usage for SM 1.9+
Browse files Browse the repository at this point in the history
The `MatchRegex` function's return value was changed in SourceMod 1.9, so update the checks in a backwards compatible way.
  • Loading branch information
peace-maker committed Jun 13, 2019
1 parent 1f45439 commit 8367920
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripting/websocket.sp
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ public OnChildSocketReceive(Handle:socket, const String:receiveData[], const dat
new RegexError:iRegexError;
// Get the key
new iSubStrings = MatchRegex(g_hRegExKey, receiveData, iRegexError);
if(iSubStrings == -1)
if(iSubStrings <= 0)
{
LogError("Can't find the Key in the http protocol upgrade request.");
CloseChildSocket(iIndex);
Expand All @@ -755,7 +755,7 @@ public OnChildSocketReceive(Handle:socket, const String:receiveData[], const dat

iSubStrings = MatchRegex(g_hRegExProtocol, receiveData, iRegexError);
decl String:sProtocol[256];
if(iSubStrings != -1)
if(iSubStrings > 0)
{
if(!GetRegexSubString(g_hRegExProtocol, 1, sProtocol, sizeof(sProtocol)))
{
Expand All @@ -769,9 +769,9 @@ public OnChildSocketReceive(Handle:socket, const String:receiveData[], const dat

decl String:sPath[URL_MAX_LENGTH];

// Get the key
// Get the path
iSubStrings = MatchRegex(g_hRegExPath, receiveData, iRegexError);
if(iSubStrings == -1 || !GetRegexSubString(g_hRegExPath, 1, sPath, sizeof(sPath)))
if(iSubStrings <= 0 || !GetRegexSubString(g_hRegExPath, 1, sPath, sizeof(sPath)))
sPath = "";

// Inform plugins, there's an incoming request
Expand Down

0 comments on commit 8367920

Please sign in to comment.