Template::expandAll swapped every expression notation in the raw template
string with str_replace, so the literal text surrounding the expressions was
copied verbatim and never percent encoded. The expression detection pattern is
now used to split the template into an ordered list of parts: literals are
encoded once at construction, expressions stay Expression objects, and the
expansion simply concatenates them. Keeping the parts apart is what prevents
the already encoded expansion results from being encoded a second time.
Fixes the "Additional Examples 8: Literal Encoding" case of the vendored
uritemplate-test compliance suite.
Operator::inject() applied the ":N" prefix modifier with the
byte-oriented substr(), splitting multibyte UTF-8 characters in half
and producing invalid percent-encoded output (e.g. the euro sign
truncated to its first byte only).
RFC 6570 Section 2.4.1 defines the prefix length as a count of
characters, so use mb_substr() with an explicit UTF-8 encoding
instead. ext-mbstring is already a hard dependency of this package.