Skip to content

Commit

Permalink
Improve regex to handle nested comments more efficiently (#1164)
Browse files Browse the repository at this point in the history
ensure that the regex does not backtrack excessively
  • Loading branch information
ready-research authored Oct 8, 2024
1 parent c79e20a commit c53d0c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class HttpClient implements IHttpClient {
if (typeof body === 'string') {
// Remove any extra characters that appear before or after the SOAP envelope.
const regex = /(?:<\?[^?]*\?>[\s]*)?<([^:]*):Envelope([\S\s]*)<\/\1:Envelope>/i;
const match = body.replace(/<!--[\s\S]*?-->/, '').match(regex);
const match = body.replace(/<!--(?:(?!<!--[\s\S])*?)-->/, '').match(regex);
if (match) {
body = match[0];
}
Expand Down

0 comments on commit c53d0c8

Please sign in to comment.