@@ -4782,20 +4782,29 @@ function trustedReplaceOutboundText(
47824782 const extraArgs = safe . getExtraArgs ( args ) ;
47834783 const reCondition = safe . patternToRegex ( extraArgs . condition || '' ) ;
47844784 const reflector = proxyApplyFn ( propChain , function ( ...args ) {
4785- const textBefore = reflector ( ...args ) ;
4785+ const encodedTextBefore = reflector ( ...args ) ;
4786+ let textBefore = encodedTextBefore ;
4787+ if ( extraArgs . encoding === 'base64' ) {
4788+ try { textBefore = self . atob ( encodedTextBefore ) ; }
4789+ catch ( ex ) { return encodedTextBefore ; }
4790+ }
47864791 if ( pattern === '' ) {
4787- safe . uboLog ( logPrefix , 'Outbound text:\n' , textBefore ) ;
4788- return textBefore ;
4792+ safe . uboLog ( logPrefix , 'Decoded outbound text:\n' , textBefore ) ;
4793+ return encodedTextBefore ;
47894794 }
47904795 reCondition . lastIndex = 0 ;
4791- if ( reCondition . test ( textBefore ) === false ) { return textBefore ; }
4796+ if ( reCondition . test ( textBefore ) === false ) { return encodedTextBefore ; }
47924797 const textAfter = textBefore . replace ( rePattern , replacement ) ;
4793- if ( textAfter === textBefore ) { return textBefore ; }
4798+ if ( textAfter === textBefore ) { return encodedTextBefore ; }
47944799 safe . uboLog ( logPrefix , 'Matched and replaced' ) ;
47954800 if ( safe . logLevel > 1 ) {
4796- safe . uboLog ( logPrefix , 'Modified outbound text:\n' , textAfter ) ;
4801+ safe . uboLog ( logPrefix , 'Modified decoded outbound text:\n' , textAfter ) ;
4802+ }
4803+ let encodedTextAfter = textAfter ;
4804+ if ( extraArgs . encoding === 'base64' ) {
4805+ encodedTextAfter = self . btoa ( textAfter ) ;
47974806 }
4798- return textAfter ;
4807+ return encodedTextAfter ;
47994808 } ) ;
48004809}
48014810
0 commit comments