@@ -192,7 +192,7 @@ function abortCurrentScriptCore(
192192 const reContext = safe . patternToRegex ( context ) ;
193193 const extraArgs = safe . getExtraArgs ( Array . from ( arguments ) , 3 ) ;
194194 const thisScript = document . currentScript ;
195- const chain = target . split ( '.' ) ;
195+ const chain = safe . String_split . call ( target , '.' ) ;
196196 let owner = window ;
197197 let prop ;
198198 for ( ; ; ) {
@@ -406,6 +406,7 @@ builtinScriptlets.push({
406406 dependencies : [
407407 'matches-stack-trace.fn' ,
408408 'object-find-owner.fn' ,
409+ 'safe-self.fn' ,
409410 ] ,
410411} ) ;
411412// When no "prune paths" argument is provided, the scriptlet is
@@ -422,11 +423,12 @@ function objectPruneFn(
422423 extraArgs = { }
423424) {
424425 if ( typeof rawPrunePaths !== 'string' ) { return ; }
426+ const safe = safeSelf ( ) ;
425427 const prunePaths = rawPrunePaths !== ''
426- ? rawPrunePaths . split ( / + / )
428+ ? safe . String_split . call ( rawPrunePaths , / + / )
427429 : [ ] ;
428430 const needlePaths = prunePaths . length !== 0 && rawNeedlePaths !== ''
429- ? rawNeedlePaths . split ( / + / )
431+ ? safe . String_split . call ( rawNeedlePaths , / + / )
430432 : [ ] ;
431433 if ( stackNeedleDetails . matchAll !== true ) {
432434 if ( matchesStackTrace ( stackNeedleDetails , extraArgs . logstack ) === false ) {
@@ -547,7 +549,7 @@ function matchesStackTrace(
547549 // Normalize stack trace
548550 const reLine = / ( .* ?@ ) ? ( \S + ) ( : \d + ) : \d + \) ? $ / ;
549551 const lines = [ ] ;
550- for ( let line of error . stack . split ( / [ \n \r ] + / ) ) {
552+ for ( let line of safe . String_split . call ( error . stack , / [ \n \r ] + / ) ) {
551553 if ( line . includes ( exceptionToken ) ) { continue ; }
552554 line = line . trim ( ) ;
553555 const match = safe . RegExp_exec . call ( reLine , line ) ;
@@ -594,8 +596,8 @@ function parsePropertiesToMatch(propsToMatch, implicit = '') {
594596 const needles = new Map ( ) ;
595597 if ( propsToMatch === undefined || propsToMatch === '' ) { return needles ; }
596598 const options = { canNegate : true } ;
597- for ( const needle of propsToMatch . split ( / \s + / ) ) {
598- const [ prop , pattern ] = needle . split ( ':' ) ;
599+ for ( const needle of safe . String_split . call ( propsToMatch , / \s + / ) ) {
600+ const [ prop , pattern ] = safe . String_split . call ( needle , ':' ) ;
599601 if ( prop === '' ) { continue ; }
600602 if ( pattern !== undefined ) {
601603 needles . set ( prop , safe . initPattern ( pattern , options ) ) ;
@@ -1643,7 +1645,7 @@ function noFetchIf(
16431645 const safe = safeSelf ( ) ;
16441646 const logPrefix = safe . makeLogPrefix ( 'prevent-fetch' , propsToMatch , responseBody , responseType ) ;
16451647 const needles = [ ] ;
1646- for ( const condition of propsToMatch . split ( / \s + / ) ) {
1648+ for ( const condition of safe . String_split . call ( propsToMatch , / \s + / ) ) {
16471649 if ( condition === '' ) { continue ; }
16481650 const pos = condition . indexOf ( ':' ) ;
16491651 let key , value ;
@@ -1797,7 +1799,7 @@ function removeClass(
17971799 if ( rawToken === '' ) { return ; }
17981800 const safe = safeSelf ( ) ;
17991801 const logPrefix = safe . makeLogPrefix ( 'remove-class' , rawToken , rawSelector , behavior ) ;
1800- const tokens = rawToken . split ( / \s * \| \s * / ) ;
1802+ const tokens = safe . String_split . call ( rawToken , / \s * \| \s * / ) ;
18011803 const selector = tokens
18021804 . map ( a => `${ rawSelector } .${ CSS . escape ( a ) } ` )
18031805 . join ( ',' ) ;
@@ -2510,12 +2512,12 @@ function m3uPrune(
25102512 }
25112513 text = before . trim ( ) + '\n' + after . trim ( ) ;
25122514 reM3u . lastIndex = before . length + 1 ;
2513- toLog . push ( 'Discarding' , ...discard . split ( / \n + / ) . map ( s => `\t${ s } ` ) ) ;
2515+ toLog . push ( 'Discarding' , ...safe . String_split . call ( discard , / \n + / ) . map ( s => `\t${ s } ` ) ) ;
25142516 if ( reM3u . global === false ) { break ; }
25152517 }
25162518 return text ;
25172519 }
2518- const lines = text . split ( / \n \r | \n | \r / ) ;
2520+ const lines = safe . String_split . call ( text , / \n \r | \n | \r / ) ;
25192521 for ( let i = 0 ; i < lines . length ; i ++ ) {
25202522 if ( lines [ i ] === undefined ) { continue ; }
25212523 if ( pruneSpliceoutBlock ( lines , i ) ) { continue ; }
@@ -2758,13 +2760,17 @@ function hrefSanitizer(
27582760builtinScriptlets . push ( {
27592761 name : 'call-nothrow.js' ,
27602762 fn : callNothrow ,
2763+ dependencies : [
2764+ 'safe-self.fn' ,
2765+ ] ,
27612766} ) ;
27622767function callNothrow (
27632768 chain = ''
27642769) {
27652770 if ( typeof chain !== 'string' ) { return ; }
27662771 if ( chain === '' ) { return ; }
2767- const parts = chain . split ( '.' ) ;
2772+ const safe = safeSelf ( ) ;
2773+ const parts = safe . String_split . call ( chain , '.' ) ;
27682774 let owner = window , prop ;
27692775 for ( ; ; ) {
27702776 prop = parts . shift ( ) ;
@@ -3095,7 +3101,7 @@ function trustedClickElement(
30953101 const logPrefix = safe . makeLogPrefix ( 'trusted-click-element' , selectors , extraMatch , delay ) ;
30963102
30973103 if ( extraMatch !== '' ) {
3098- const assertions = extraMatch . split ( ',' ) . map ( s => {
3104+ const assertions = safe . String_split . call ( extraMatch , ',' ) . map ( s => {
30993105 const pos1 = s . indexOf ( ':' ) ;
31003106 const s1 = pos1 !== - 1 ? s . slice ( 0 , pos1 ) : s ;
31013107 const not = s1 . startsWith ( '!' ) ;
@@ -3163,7 +3169,7 @@ function trustedClickElement(
31633169 return shadowRoot && querySelectorEx ( inside , shadowRoot ) ;
31643170 } ;
31653171
3166- const selectorList = selectors . split ( / \s * , \s * / )
3172+ const selectorList = safe . String_split . call ( selectors , / \s * , \s * / )
31673173 . filter ( s => {
31683174 try {
31693175 void querySelectorEx ( s ) ;
@@ -3290,10 +3296,10 @@ function trustedPruneInboundObject(
32903296 const extraArgs = safe . getExtraArgs ( Array . from ( arguments ) , 4 ) ;
32913297 const needlePaths = [ ] ;
32923298 if ( rawPrunePaths !== '' ) {
3293- needlePaths . push ( ...rawPrunePaths . split ( / + / ) ) ;
3299+ needlePaths . push ( ...safe . String_split . call ( rawPrunePaths , / + / ) ) ;
32943300 }
32953301 if ( rawNeedlePaths !== '' ) {
3296- needlePaths . push ( ...rawNeedlePaths . split ( / + / ) ) ;
3302+ needlePaths . push ( ...safe . String_split . call ( rawNeedlePaths , / + / ) ) ;
32973303 }
32983304 const stackNeedle = safe . initPattern ( extraArgs . stackToMatch || '' , { canNegate : true } ) ;
32993305 const mustProcess = root => {
@@ -3455,7 +3461,7 @@ function trustedSuppressNativeMethod(
34553461 if ( stack !== '' ) { return ; }
34563462 const safe = safeSelf ( ) ;
34573463 const logPrefix = safe . makeLogPrefix ( 'trusted-suppress-native-method' , methodPath , signature , how ) ;
3458- const signatureArgs = signature . split ( / \s * \| \s * / ) . map ( v => {
3464+ const signatureArgs = safe . String_split . call ( signature , / \s * \| \s * / ) . map ( v => {
34593465 if ( / ^ " .* " $ / . test ( v ) ) {
34603466 return { type : 'pattern' , re : safe . patternToRegex ( v . slice ( 1 , - 1 ) ) } ;
34613467 }
0 commit comments