setFromIdentity located the previous signature by embedding its HTML
in a regular expression. Metacharacters, plain text and CKEditor's
<br> serialization made the search miss, and the regex-too-large
fallback appended the new signature.
The delimiter is now matched with a fixed-size pattern. The signature
body is compared as text, from the end of the break that follows the
dash. A missed match is null. One missing blank line before the
delimiter is still recognized.
Fixes#6168Fixes#6214Fixes#5695
NGSocketAddressFromString answers the first family returned by
getaddrinfo, and resolvers on dual-stack hosts may answer ::1 before
127.0.0.1 for localhost, so the IPv4 expectation for that name cannot be
guaranteed on every host.
generateMessageID: appended the substring following the last '@'
without sanitizing it, so a sender value such as 'Doe, John <a@b>'
produced 'Message-Id: <uuid@b>>' with a duplicated closing bracket on
calendar invitations. A nil domain also left the message-id
unterminated.
The domain part is now cut at the first address delimiter or
whitespace - a domain is a single token, and anything else would
allow header injection through generated message-ids.
Fixes#6201
the trailing while loop reuses the regex variable, which by then points at the
angular brace pattern whenever stripAngular is YES. that pattern has two
capture groups while the loop substitutes $1@im****$3, so NSRegularExpression
raises NSInvalidArgumentException and the NS_HANDLER swallows it.
give the @import pattern its own variable and use it in both the replacement
and the loop. the replacement also used the template of the block above, which
dropped the whole style element instead of masking the @import in place, so
test_stringWithoutHTMLInjection failed. it passes again, and a case with
stripAngular YES covers the loop.