Merge pull request #7897 from thess/localhost-debug-fix

Fix web-editor debug on non-standard port using localhost (CORS)
This commit is contained in:
Scott Shawcroft 2023-04-24 10:17:49 -07:00 committed by GitHub
commit 029c941f72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -478,8 +478,12 @@ static bool _origin_ok(_request *request) {
return true; return true;
} }
// DEBUG: OK if origin is 'localhost' (ignoring port #) // DEBUG: OK if origin is 'localhost' (ignoring port #)
*strchrnul(&request->origin[PREFIX_HTTP_LEN], ':') = '\0'; char *cptr = strchrnul(&request->origin[PREFIX_HTTP_LEN], ':');
char csave = *cptr; // NULL or colon
*cptr = '\0';
if (strcmp(&request->origin[PREFIX_HTTP_LEN], "localhost") == 0) { if (strcmp(&request->origin[PREFIX_HTTP_LEN], "localhost") == 0) {
// Restore removed colon if non-null host terminator
*cptr = csave;
return true; return true;
} }
} }