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

|strip_tags:true filter does not work if the input is exactly the number 0 #890

Closed
ghost opened this issue Jul 12, 2023 · 1 comment · Fixed by #893
Closed

|strip_tags:true filter does not work if the input is exactly the number 0 #890

ghost opened this issue Jul 12, 2023 · 1 comment · Fixed by #893

Comments

@ghost
Copy link

ghost commented Jul 12, 2023

Reproduction:

$x=0;
{$x|strip_tags}

Expected:
0
Result:
Empty string

The Problem was introduced in https://github.com/smarty-php/smarty/blob/master/libs/plugins/modifiercompiler.strip_tags.php when a deprecation error was fixed here 612bd3f

The operator ? is a soft == instead of ?? which checks for hard empty.

Solution:
Check for 0 or use "??", but this would similar to #882

Alterantive Solution:
Check if the string even contains a "<" and then just return it, if not, then you save the whole regex.

Additional: The documenation on the true/false parameter is very unclear https://www.smarty.net/docs/en/language.modifier.strip.tags.tpl as it is hard to visualize the space when a linebreak is in the documentation, adding a sentence explaining the space or no space paradigma would help a lot.

@scottchiefbaker
Copy link

That code isn't easily readable. Couldn't you simplify the entire thing with something like:

$x = $params[1];
if (!is_string($x)) {
    return $x;
} else {
    return strip_tags($x);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant