Refuse in a text field what the bus will refuse #7
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Catcrafts/Nostro#7
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A text field of the app takes text that D-Bus will not carry. The form shows it, and sending the form fails with "text that is not UTF-8 cannot be sent to nostrod. Nothing was sent.", for text that may well be UTF-8. The user is not told which character is at fault, and it may be one the font draws nothing for.
Found by the pre-push review of 1.0.0 (the approach and bug-prover lenses). It is older than that release. Since 1.0.0 the reader of pay links keeps such text out of a form a link fills in (
Plain()inNostro.App-Forms.cpp), by checks of its own beside the decoder; a field that is typed or pasted into has no such check.Where
Links are to the tree at
8dd31e2(1.0.0).Ui::DecodeUtf8gives U+FFFD for a byte that begins nothing and for a sequence cut short. It takes a sequence longer than its character needs (C0 AFreads as/), half of a surrogate pair (ED A0 80), a code point past U+10FFFF (F4 90 80 80) and the noncharacters (U+FDD0 to U+FDEF, and the last two code points of every plane).Taken, which decides what a field keeps of what is typed or pasted, keeps in a field of text every code point from U+0020 up but U+007F and a U+FFFD that is not its own three bytes. A field of digits keeps what decodes to a digit, in the bytes it came in, an over-long5among them. Its comment gives the aim: "the bus carries valid UTF-8 alone".Wire<std::string>::Append), andExplainwords that as input the user got wrong.Concrete case
Paste a description that holds U+1FFFE (
F0 9F BF BE) into the pay form. The field keeps it; what the font draws for it was not looked at. Press Pay: "That cannot be done. text that is not UTF-8 cannot be sent to nostrod. Nothing was sent." The same goes for an over-long sequence, which the field draws as the character it spells.No money moves, and nothing reaches a dialog or the bank: the call is never sent.
What it would take
DecodeUtf8give U+FFFD for an over-long sequence, a surrogate and a code point past U+10FFFF.Takenthen drops them as it drops any malformed sequence, andPlain()inNostro.App-Forms.cppcan lose its own check for the shortest form.Takendrop the noncharacters as well, which are valid UTF-8 and which sd-bus refuses all the same. The library'sUnshownlacks those of the planes after the first as well: #6.ShouldEditTextgets the cases: each of these pasted into a field of each kind.What was run, and what was read
Run, against libsystemd 262.1:
sd_bus_message_append_basicwith typesreturns-EINVALfor U+FFFE, U+FDD0, U+1FFFE, U+2FFFF, U+EFFFF and U+10FFFF, for an over-long sequence and for a character cut short, and takes private use (U+E000, U+F0000). That the decoder andTakenlet these through is from reading the code, and fromShouldValidateForms, whose cases for a link's over-long and noncharacter text pass only throughPlain()'s own checks. Pasting into the running app was not tried.