]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix overwriting original vars when logging
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Thu, 16 Jun 2022 11:30:52 +0000 (13:30 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Thu, 16 Jun 2022 16:36:58 +0000 (18:36 +0200)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
lib/private/Log/ExceptionSerializer.php
tests/lib/Log/ExceptionSerializerTest.php

index dab134b26a4d315c3d7b35076c4ad408b4eff80f..a792f966edaf32eafc5c1dd501375809a92b626d 100644 (file)
@@ -208,14 +208,16 @@ class ExceptionSerializer {
        }
 
        private function removeValuesFromArgs($args, $values) {
-               foreach ($args as &$arg) {
+               $workArgs = [];
+               foreach ($args as $arg) {
                        if (in_array($arg, $values, true)) {
                                $arg = '*** sensitive parameter replaced ***';
                        } elseif (is_array($arg)) {
                                $arg = $this->removeValuesFromArgs($arg, $values);
                        }
+                       $workArgs[] = $arg;
                }
-               return $args;
+               return $workArgs;
        }
 
        private function encodeTrace($trace) {
index 1b7bfee2c87e55bdd668e1e2ea7c875e7065adfd..f8cc6b77ee6c88e54d563787e87cc3935ba0f31f 100644 (file)
@@ -60,8 +60,9 @@ class ExceptionSerializerTest extends TestCase {
                        $secret = ['Secret'];
                        $this->emit([&$secret]);
                } catch (\Exception $e) {
-                       $this->serializer->serializeException($e);
+                       $serializedData = $this->serializer->serializeException($e);
                        $this->assertSame(['Secret'], $secret);
+                       $this->assertSame('*** sensitive parameters replaced ***', $serializedData['Trace'][0]['args'][0]);
                }
        }
 }