Skip to content

Develop (22 Beta) - MAIN_RESTRICTHTML_ONLY_VALID_HTML forced to 1, wrong preg_replace #34323

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

Open
warnerbryce opened this issue May 30, 2025 · 0 comments
Labels
Bug This is a bug (something does not work as expected)

Comments

@warnerbryce
Copy link
Contributor

Bug

Hello,
There is a problem with function dol_htmlwithnojs since Dolibarr 22 because MAIN_RESTRICTHTML_ONLY_VALID_HTML is activated by default on 1.
htdocs/core/class line 1330
I have the same problem on Dolibarr 21 if i enable const : MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1
I don't have this problem on Dolibarr 20 if i enable const : MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1

I don't know why I got this when function multiSelectArrayWithCheckbox is called.

Image

Following the function dol_htmlwithnojs I enter in the IF of line 8773 of htdocs/core/lib/functions.lib.php :
if (!empty($out) && getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML') && $check != 'restricthtmlallowunvalid')

All of this works well until line 8795 :
$out = trim($dom->saveHTML());
Before line 8795 :
$out = <?xml encoding="UTF-8"><div class="tricktoremove">
After line 8795 :
$out = <!--?xml encoding="UTF-8"><div class="tricktoremove"-->

So preg_replace that is just after won't work.

I am not skilled enough on the DOM side of things but there is something to troubleshoot here.
Thanks

Dolibarr Version

21.0, develop

Environment PHP

8.2

Environment Database

Mariadb 11.7

Steps to reproduce the behavior and expected behavior

Having the constant MAIN_RESTRICTHTML_ONLY_VALID_HTML enabled.
Browsing a page where function multiSelectArrayWithCheckbox is called, like list of invoices

Attached files

No response

@warnerbryce warnerbryce added the Bug This is a bug (something does not work as expected) label May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug (something does not work as expected)
Projects
None yet
Development

No branches or pull requests

1 participant