commit 8be8cf9: [Minor] Css: Make debug output valid json
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Mar 4 20:42:05 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-03-04 15:40:34 +0000
URL: https://github.com/rspamd/rspamd/commit/8be8cf9bcd4047c17cf9f8b95b0831ecbf22d8ae
[Minor] Css: Make debug output valid json
---
src/libserver/css/css_parser.cxx | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/libserver/css/css_parser.cxx b/src/libserver/css/css_parser.cxx
index 014ddf680..1d2916e5e 100644
--- a/src/libserver/css/css_parser.cxx
+++ b/src/libserver/css/css_parser.cxx
@@ -74,7 +74,7 @@ auto css_consumed_block::token_type_str(void) const -> const char *
ret = "function";
break;
case parser_tag_type::css_function_arg:
- ret = "function args";
+ ret = "function arg";
break;
case parser_tag_type::css_component:
ret = "component";
@@ -119,15 +119,19 @@ auto css_consumed_block::debug_str(void) -> std::string {
}
else if constexpr (std::is_same_v<T, css_function_block>) {
/* Empty block */
- ret += R"({ "function:" {"name": )";
- ret += "\"" + arg.function.debug_token_str() + "\"";
- ret += R"("arguments:" [)";
+ ret += R"({ "content": {"token": )";
+ ret += "\"" + arg.function.debug_token_str() + "\", ";
+ ret += R"("arguments": [)";
for (const auto &block : arg.args) {
ret += "{";
ret += block->debug_str();
ret += "}, ";
}
- ret += "]}";
+ if (*(--ret.end()) == ' ') {
+ ret.pop_back();
+ ret.pop_back(); /* Last ',' */
+ }
+ ret += "]}}";
}
else {
/* Single element block */
More information about the Commits
mailing list