Fix #16233 - ~{} works on colorized JSONs ##json (#16425)

* Fix #16233 - ~{} works on colorized JSONs ##json
* Fix issue in json_indent
This commit is contained in:
pancake 2020-04-06 04:08:47 -04:00 committed by GitHub
parent 5621f4030d
commit d95befca7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -514,9 +514,12 @@ R_API void r_cons_grepbuf() {
Color_RESET,
NULL
};
char *bb = strdup (buf);
r_str_ansi_filter (bb, NULL, NULL, -1);
char *out = (cons->context->grep.human)
? r_print_json_human (buf)
: r_print_json_indent (buf, I (context->color_mode), " ", palette);
? r_print_json_human (bb)
: r_print_json_indent (bb, I (context->color_mode), " ", palette);
free (bb);
if (!out) {
return;
}

View File

@ -326,11 +326,13 @@ R_API char* r_print_json_indent(const char* s, bool color, const char* tab, cons
case ':':
*o++ = *s;
*o++ = ' ';
if (!strncmp (s + 1, "true", 4)) {
s = r_str_trim_head_ro (s + 1);
if (!strncmp (s, "true", 4)) {
EMIT_ESC (o, colors[JC_TRUE]);
} else if (!strncmp (s + 1, "false", 5)) {
} else if (!strncmp (s, "false", 5)) {
EMIT_ESC (o, colors[JC_FALSE]);
}
s--;
isValue = true;
break;
case ',':