Reset potential `g` regex before use in `replace=` option

Related discussion:
https://github.com/uBlockOrigin/uAssets/issues/5184#issuecomment-1794058253
This commit is contained in:
Raymond Hill 2023-11-06 07:16:41 -05:00
parent b2bf5c255e
commit 5d1618e1be
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 4 additions and 2 deletions

View File

@ -602,10 +602,10 @@ const mimeFromHeaders = headers => {
const mimeFromContentType = contentType => { const mimeFromContentType = contentType => {
const match = reContentTypeMime.exec(contentType); const match = reContentTypeMime.exec(contentType);
if ( match === null ) { return ''; } if ( match === null ) { return ''; }
return match[1].toLowerCase(); return match[0].toLowerCase();
}; };
const reContentTypeMime = /^([^;]+)(?:;|$)/i; const reContentTypeMime = /^[^;]+/i;
/******************************************************************************/ /******************************************************************************/
@ -619,7 +619,9 @@ function textResponseFilterer(session, directives) {
} }
const cache = refs.$cache; const cache = refs.$cache;
if ( cache === undefined ) { continue; } if ( cache === undefined ) { continue; }
cache.re.lastIndex = 0;
if ( cache.re.test(session.getString()) !== true ) { continue; } if ( cache.re.test(session.getString()) !== true ) { continue; }
cache.re.lastIndex = 0;
session.setString(session.getString().replace( session.setString(session.getString().replace(
cache.re, cache.re,
cache.replacement cache.replacement