@@ -102,6 +102,36 @@ QyNTUxOQAAACBA1m7X8J9H6P8Q9J8H6P8Q9J8H6P8Q9J8H6P8Q9J8H6Q==
102102 expect (out, contains ('mysql://root:${SandboxSanitizer .redactionToken }@' ));
103103 expect (out, contains ('mongodb+srv://admin:${SandboxSanitizer .redactionToken }@' ));
104104 });
105+
106+ test ('redacts quoted passwords and tokens containing spaces (#918)' , () {
107+ final input = [
108+ '{"password": "correct horse battery staple"}' ,
109+ "val = {'api_key': 'super secret key with spaces'};" ,
110+ 'password: "my secret password123"' ,
111+ "access_token: 'token with multiple spaces inside'" ,
112+ 'auth-token = "auth token with spaces"' ,
113+ 'password=plainSecret&other=1' ,
114+ '{"secret": "nested \\ "quoted\\ " secret", "status": "ok"}' ,
115+ ].join ('\n ' );
116+
117+ final out = SandboxSanitizer .sanitize (input);
118+
119+ expect (out, isNot (contains ('correct horse battery staple' )));
120+ expect (out, isNot (contains ('super secret key with spaces' )));
121+ expect (out, isNot (contains ('my secret password123' )));
122+ expect (out, isNot (contains ('token with multiple spaces inside' )));
123+ expect (out, isNot (contains ('auth token with spaces' )));
124+ expect (out, isNot (contains ('plainSecret' )));
125+ expect (out, isNot (contains ('nested \\ "quoted\\ " secret' )));
126+
127+ expect (out, contains ('{"password": "${SandboxSanitizer .redactionToken }"}' ));
128+ expect (out, contains ("{'api_key': '${SandboxSanitizer .redactionToken }'}" ));
129+ expect (out, contains ('password: "${SandboxSanitizer .redactionToken }"' ));
130+ expect (out, contains ("access_token: '${SandboxSanitizer .redactionToken }'" ));
131+ expect (out, contains ('auth-token = "${SandboxSanitizer .redactionToken }"' ));
132+ expect (out, contains ('password=${SandboxSanitizer .redactionToken }&other=1' ));
133+ expect (out, contains ('{"secret": "${SandboxSanitizer .redactionToken }", "status": "ok"}' ));
134+ });
105135 });
106136
107137 group ('SandboxRotatingLog' , () {
0 commit comments