A hexadecimal escape in a string takes in the first letters of the word after it

tx0/cpp:hex-escape-swallows-digitsrecommendedwarningreliability/strings-and-regexdepth fastbug

What it finds

"\x01FIND" meant as the byte 1 followed by FIND: a \x escape takes in every hexadecimal digit after it, so the string holds \x01F and then IND. Splitting the literal, "\x01" "FIND", ends the escape.

A narrow string accepts only escapes whose value fits a byte, so in code that compiles the extra digits follow leading zeros. Such an escape, "\x0ff", may be meant as written; the rule reports it only when a letter that is no hexadecimal digit follows right after the digits, so that the escape cuts a word in two.

From the rule's source, hex_escape_swallows_digits.rs.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/cpp:hex-escape-swallows-digits" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/cpp:hex-escape-swallows-digits] reason="..."

tx0 explain tx0/cpp:hex-escape-swallows-digits shows the same in the terminal. Found a false positive? Report it.