Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass charset to escaper callback again #4088

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Extension/EscaperExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function setEscaper($strategy, callable $callable)

$this->escapers[$strategy] = $callable;
$callable = function ($string, $charset) use ($callable) {
return $callable($this->environment, $string);
return $callable($this->environment, $string, $this->environment->getCharset());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was indeed a mistake. I don't think we should restore this odd behavior as the callables never got the charset before (so without changing the escapers, the charset is not useful). And as adding the charset does not make migrating easier, I don't think we should support it.

Copy link
Author

@fritzmg fritzmg May 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the callables never got the charset before

Not sure what you mean? The callables did get the charset before:

return $escapers[$strategy]($env, $string, $charset);

That's the BC break.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm stupid sometimes. See #4091 for the fix. Here, we need the charset passed to the escape filter, not the default charset.

};

$this->escaper->setEscaper($strategy, $callable);
Expand Down
Loading