Bad behaviour with multiple curly braces in format string
Closed this issue · 2 comments
Hello,
I believe #158 introduced a bug when a to-be-formatted string contains multiple curly braces:
Before 1.83.0, the following snippet:
#include <boost/locale.hpp>
#include <boost/format.hpp>
#include <iostream>
int main() {
std::cout << boost::locale::format("Test string {{{1}}}") % "num";
return 0;
}
Returned:
Test String {{num}}
After 1.83.0 it returns:
Test string {{num}
I admit this is sort of an edge case, but I feel like the previous behaviour was more correct.
I'm not sure how that specific PR could cause that behavior, but I agree that neither version produces what I'd expect.
Edit: it is rather caused by a refactoring which misses skipping the escaped opening brace
boost::locale::format("Test string {{{1}}}") % "num"
should IMO yield Test string {num}
as per the documentation:
You can include a literal '{' and '}' by inserting double "{{" or "}}" into the text.
--> There is an escaped brace, a format-placeholder and another escaped brace
Thanks for the fix!