From 592a5c94a110f44073f7b92f9d4dfe313f3cdf93 Mon Sep 17 00:00:00 2001 From: Richard M Kreuter <186215+kreuter@users.noreply.github.com> Date: Sun, 30 May 2021 07:52:14 -0400 Subject: Escape all string values output by the lisp report. Notes were already being escaped. The filename, the transaction code, the payee,, postings' account names, and postings' cost expressions were not. Everything else the lisp report prints appears to be a number or a constant-valued non-string token for Lisp. --- src/emacs.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/emacs.cc') diff --git a/src/emacs.cc b/src/emacs.cc index 52389316..9092bb4b 100644 --- a/src/emacs.cc +++ b/src/emacs.cc @@ -41,7 +41,7 @@ namespace ledger { void format_emacs_posts::write_xact(xact_t& xact) { if (xact.pos) - out << "\"" << xact.pos->pathname.string() << "\" " + out << "\"" << escape_string(xact.pos->pathname.string()) << "\" " << xact.pos->beg_line << " "; else out << "\"\" " << -1 << " "; @@ -52,14 +52,14 @@ namespace ledger { out << "(" << (date / 65536) << " " << (date % 65536) << " 0) "; if (xact.code) - out << "\"" << *xact.code << "\" "; + out << "\"" << escape_string(*xact.code) << "\" "; else out << "nil "; if (xact.payee.empty()) out << "nil"; else - out << "\"" << xact.payee << "\""; + out << "\"" << escape_string(xact.payee) << "\""; out << "\n"; } @@ -85,8 +85,8 @@ namespace ledger { else out << " (" << -1 << " "; - out << "\"" << post.reported_account()->fullname() << "\" \"" - << post.amount << "\""; + out << "\"" << escape_string(post.reported_account()->fullname()) << "\" \"" + << escape_string(post.amount) << "\""; switch (post.state()) { case item_t::UNCLEARED: @@ -101,7 +101,7 @@ namespace ledger { } if (post.cost) - out << " \"" << *post.cost << "\""; + out << " \"" << escape_string(*post.cost) << "\""; if (post.note) out << " \"" << escape_string(*post.note) << "\""; out << ")"; -- cgit v1.2.3