strings_print json: For efficiency, escape strings only once (#4396)
This commit is contained in:
parent
508bbae8a5
commit
cfac4b2ae1
1 changed files with 10 additions and 8 deletions
|
|
@ -2725,11 +2725,15 @@ static bool strings_print(RzCore *core, RzCmdStateOutput *state, const RzPVector
|
|||
}
|
||||
}
|
||||
|
||||
RzStrEscOptions opt = { 0 };
|
||||
opt.show_asciidot = false;
|
||||
opt.esc_bslash = true;
|
||||
opt.esc_double_quotes = false;
|
||||
char *escaped_string = rz_str_escape_utf8_keep_printable(string->string, &opt);
|
||||
char *escaped_string = NULL;
|
||||
// For JSON, pj_ks does the escaping
|
||||
if (state->mode != RZ_OUTPUT_MODE_JSON && state->mode != RZ_OUTPUT_MODE_LONG_JSON) {
|
||||
RzStrEscOptions opt = { 0 };
|
||||
opt.show_asciidot = false;
|
||||
opt.esc_bslash = true;
|
||||
opt.esc_double_quotes = false;
|
||||
escaped_string = rz_str_escape_utf8_keep_printable(string->string, &opt);
|
||||
}
|
||||
|
||||
switch (state->mode) {
|
||||
case RZ_OUTPUT_MODE_JSON: {
|
||||
|
|
@ -2742,9 +2746,7 @@ static bool strings_print(RzCore *core, RzCmdStateOutput *state, const RzPVector
|
|||
pj_kn(state->d.pj, "length", string->length);
|
||||
pj_ks(state->d.pj, "section", section_name);
|
||||
pj_ks(state->d.pj, "type", type_string);
|
||||
// data itself may be encoded so use pj_ks.
|
||||
// string->string is used instead of escaped_string
|
||||
// because it's pj_ks that does the escaping.
|
||||
// data itself may be encoded so use pj_ks
|
||||
pj_ks(state->d.pj, "string", string->string);
|
||||
|
||||
switch (string->type) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue