mirror of https://github.com/gorhill/uBlock.git
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:
parent
b2bf5c255e
commit
5d1618e1be
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue