Skip to content

Commit

Permalink
Reset potential g regex before use in replace= option
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Nov 6, 2023
1 parent b2bf5c2 commit 5d1618e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/js/traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,10 @@ const mimeFromHeaders = headers => {
const mimeFromContentType = contentType => {
const match = reContentTypeMime.exec(contentType);
if ( match === null ) { return ''; }
return match[1].toLowerCase();
return match[0].toLowerCase();
};

const reContentTypeMime = /^([^;]+)(?:;|$)/i;
const reContentTypeMime = /^[^;]+/i;

/******************************************************************************/

Expand All @@ -619,7 +619,9 @@ function textResponseFilterer(session, directives) {
}
const cache = refs.$cache;
if ( cache === undefined ) { continue; }
cache.re.lastIndex = 0;
if ( cache.re.test(session.getString()) !== true ) { continue; }
cache.re.lastIndex = 0;
session.setString(session.getString().replace(
cache.re,
cache.replacement
Expand Down

0 comments on commit 5d1618e

Please sign in to comment.