[Translation][transChoice] allows escaping the pipe character.#17662
[Translation][transChoice] allows escaping the pipe character.#17662fabpot merged 1 commit intosymfony:masterfrom
Conversation
| Q | A |
|---|---|
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Fixed tickets | #15195 |
| Tests pass? | yes |
| License | MIT |
There was a problem hiding this comment.
It doesn't work as expected with "a\\\\\|b" (escaped backslash, escaped backslash, escaped "|"). I don't think it's possible to solve it properly with a single regex.
|
@aitboudad Any news on this one? |
|
technically, this is a BC break if someone has a Btw, a simpler solution (avoiding the issue about having to escape |
|
I agree with @stof. Doubling the pipe to escape it seems the way to go. @aitboudad What do you think? |
94fd3b7 to
7974ebd
Compare
|
sounds good to me, I updated the PR! |
| public function choose($message, $number, $locale) | ||
| { | ||
| $parts = explode('|', $message); | ||
| preg_match_all('/(?:\|\|.|[^\|])+/', $message, $parts); |
There was a problem hiding this comment.
why . after the double pipe ? this would also match a pipe.
Btw, you should use a possessive quantifier to avoid useless backtracking
7974ebd to
a35a93b
Compare
|
Thank you @aitboudad. |
…aracter. (aitboudad) This PR was merged into the 3.2-dev branch. Discussion ---------- [Translation][transChoice] allows escaping the pipe character. | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Fixed tickets | #15195 | Tests pass? | yes | License | MIT Commits ------- a35a93b [Translation][transChoice] allows escaping the pipe character.