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

Wrong preg_replace pattern in class/module.textsanitizer.php in function xoopsCodeDecode #1458

Open
robekras opened this issue Mar 26, 2024 · 2 comments

Comments

@robekras
Copy link

I have upgraded to new xoops 2.5.11.
There is an issue with the xoops encoded texts like the following:

 [color=009900]This text in color[/color]
  [size=x-large]Text in large[/size]

The text should be converted to html equivalent like the following:

<span style="color: #009900;">This text in color</span>
<span style="font-size: x-large;">Text in large</span>

This is due to a change in function xoopsCodeDecode class/module.textsanitizer.php.
There are new patterns for [color] and [size], which will not work.

// 2.5.11 not working
        $patterns[]     = "/\[color=(['\"]?)([a-zA-Z0-9#]*)\\1](.*)\[\/color\]/sU";
        $replacements[] = '<span style="color: \\2;">\\3</span>';
        $patterns[]     = "/\[size=(['\"]?)([a-zA-Z0-9.#]*)\\1](.*)\[\/size\]/sU";
        $replacements[] = '<span style="font-size: \\2;">\\3</span>';

I've taken the patterns from the previous 2.5.10 which are working.

// Old one from 2.5.10 works
        $patterns[]     = "/\[color=(['\"]?)([a-zA-Z0-9]*)\\1](.*)\[\/color\]/sU";
        $replacements[] = '<span style="color: #\\2;">\\3</span>';

        $patterns[]     = "/\[size=(['\"]?)([a-z0-9-]*)\\1](.*)\[\/size\]/sU";
        $replacements[] = '<span style="font-size: \\2;">\\3</span>';
@mambax7
Copy link
Collaborator

mambax7 commented Mar 26, 2024

Thanks for the report.
Can you check if these regex patterns work for you?

$patterns[]     = "/\[color=(['\"]?)([a-zA-Z0-9#]+)\\1?](.*)\[\/color\]/sU";
$replacements[] = '<span style="color: #\\2;">\\3</span>';

$patterns[]     = "/\[size=(['\"]?)([a-zA-Z0-9-]+)\\1?](.*)\[\/size\]/sU";
$replacements[] = '<span style="font-size: \\2;">\\3</span>';

@robekras
Copy link
Author

Hi mambax7,

yes, I can confirm that these work for me.

mambax7 added a commit to mambax7/XoopsCore25 that referenced this issue Mar 28, 2024
mambax7 added a commit that referenced this issue Apr 1, 2024
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

No branches or pull requests

2 participants