checkout: an address field is one line, and the invoice prints it as text
The invoice is clearsigned, and its "Billed and shipped to" block is the
buyer's own words: name, street, postal code and city went into it as
typed. A name with a line break in it could write lines of its own into
a document the shop signs. One with no line break could still open a
heading ("# CREDIT NOTE") or, together with the street and the city, a
table, because each of those fields starts a line.
Checkout now refuses those four fields when they hold a line break or a
control character: the C0 and C1 controls, U+2028 and U+2029, and the
bidirectional embedding, override and isolate controls, which make a
line display in another order than it is stored. A tab is the
exception. A single-line input drops line breaks from a paste and keeps
tabs, so "Hoofdstraat<TAB>12" is a real buyer's address, and it is
stored with the space the tab stood for. Form::SingleLine is the one
definition of what counts.
The invoice builder applies the same function to whatever the record
holds, since a record can be older than the check or written by hand,
and prints the block indented four spaces. That is Markdown's literal
block: nothing in it is read as markup, and it reads the same as plain
text. The item in the amounts table is held to its cell too, because a
colour the catalogue no longer lists is printed as the ledger has it,
and checkout no longer stores a posted colour for a product that has no
variants.
ShouldBuildInvoices checks the property on the document (every line of
the block is blank or indented) rather than on particular strings, and
ShouldValidateForms pins the edges of each character range.
Found in the security review of 2026-11-26; the Markdown half by the
adversarial review of the first fix. No priced product is listed, so
none of it was reachable yet.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
1fb4b1c302
commit
f51105a768
5 changed files with 319 additions and 11 deletions
|
|
@ -48,9 +48,15 @@ std::string BuildInvoiceMarkdown(const OrderRecord& o,
|
|||
std::string md;
|
||||
md.reserve(2048);
|
||||
|
||||
const std::string item = colorLabel.empty()
|
||||
? std::string(productName)
|
||||
: std::format("{} — {}", productName, colorLabel);
|
||||
// The item goes into a cell of the amounts table. Its two halves come from
|
||||
// the catalogue, except that a colour the catalogue no longer lists is
|
||||
// passed through as the ledger has it, and that was once whatever was
|
||||
// posted. So it is kept to one line and cannot close its cell: a '|' here
|
||||
// would otherwise add columns to a row of a signed document.
|
||||
std::string item = Form::SingleLine(
|
||||
colorLabel.empty() ? std::string(productName)
|
||||
: std::format("{} — {}", productName, colorLabel));
|
||||
std::ranges::replace(item, '|', '/');
|
||||
|
||||
// The number scheme continues the pre-shop administration: the customer
|
||||
// number is a UUID series, the invoice number counts within it.
|
||||
|
|
@ -75,9 +81,29 @@ std::string BuildInvoiceMarkdown(const OrderRecord& o,
|
|||
md += std::format("* Paid via: {}\n", o.paidVia);
|
||||
}
|
||||
md += "\n## Billed and shipped to\n\n";
|
||||
md += std::format("{} \n{} \n{} {} \n{}\n\n",
|
||||
o.buyer.name, o.buyer.street, o.buyer.postal,
|
||||
o.buyer.city, o.buyer.country);
|
||||
// The one block of this document the buyer wrote, and it is about to be
|
||||
// signed, so it is printed as what it is: text, not markup. Two things
|
||||
// make that so, and each needs the other.
|
||||
//
|
||||
// Every field is held to ONE LINE (Form::SingleLine). Checkout refuses a
|
||||
// field that is not, but what is signed is decided here, by what is in
|
||||
// the record, and a record can be older than that check or written by
|
||||
// hand.
|
||||
//
|
||||
// And every line is indented four spaces, which is Markdown's literal
|
||||
// block: nothing in it is read as a heading, a table, a link or HTML.
|
||||
// One line alone was not enough. These fields sit at the start of
|
||||
// consecutive lines, so a name of "# CREDIT NOTE" was a heading, and a
|
||||
// name, a street and a city of "| a | b |", "|---|---|" and "| c | d |"
|
||||
// were a table, with not a line break among them (found in review,
|
||||
// 2026-11-26). Indented, they are the characters the buyer typed. It
|
||||
// also reads right as plain text, which is how this file is mostly read,
|
||||
// and a line that starts with spaces is never dash-escaped by the
|
||||
// clearsigning.
|
||||
md += std::format(" {}\n {}\n {} {}\n {}\n\n",
|
||||
Form::SingleLine(o.buyer.name), Form::SingleLine(o.buyer.street),
|
||||
Form::SingleLine(o.buyer.postal), Form::SingleLine(o.buyer.city),
|
||||
Form::SingleLine(o.buyer.country));
|
||||
|
||||
md += "## Amounts\n\n";
|
||||
md += "| Description | Qty | Amount |\n|---|---|---|\n";
|
||||
|
|
|
|||
Loading…
Reference in a new issue