feat: sanitize root folder also in php error messages (#3262)

This commit is contained in:
Dag 2023-03-06 21:47:25 +01:00 committed by GitHub
parent a01c1f6ab0
commit 007f2b2d8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 17 deletions

View file

@ -34,8 +34,8 @@ final class Logger
unset($context['e']);
$context['type'] = get_class($e);
$context['code'] = $e->getCode();
$context['message'] = $e->getMessage();
$context['file'] = trim_path_prefix($e->getFile());
$context['message'] = sanitize_root($e->getMessage());
$context['file'] = sanitize_root($e->getFile());
$context['line'] = $e->getLine();
$context['url'] = get_current_url();
$context['trace'] = trace_to_call_points(trace_from_exception($e));
@ -58,6 +58,7 @@ final class Logger
}
}
}
// Intentionally not sanitizing $message
$text = sprintf(
"[%s] rssbridge.%s %s %s\n",
now()->format('Y-m-d H:i:s'),
@ -65,6 +66,7 @@ final class Logger
$message,
$context ? Json::encode($context) : ''
);
// Log to stderr/stdout whatever that is
error_log($text);
}
}