note 126931 added to function.htmlspecialchars

From: Date: Wed, 16 Mar 2022 10:33:08 +0000
Subject: note 126931 added to function.htmlspecialchars
Groups: php.notes 
Request: Send a blank email to php-notes+get-217729@lists.php.net to get a copy of this message
Thanks Thomasvdbulk for your workaround, I would like to add a precision: When the HTML contains a link tag without new line before the script doesn't work :/ Your example: <?php $string = " this is smaller < than this<br /> this is greater > than this<br /> this is the same = as this<br /> <a href=\"http://www.example.com/example.php?test=test\">This is a link</a><br /> <b>Bold</b> <i>italic</i> etc..."; echo fixtags($string); ?> Works but this doesn't work: <?php $string = " this is smaller < than this<br /> this is greater > than this<br /> this is the same = as this<br /><a href=\"http://www.example.com/example.php?test=test\">This is a link</a><br /> <b>Bold</b> <i>italic</i> etc..."; echo fixtags($string); ?> So I add a little workaround at the beginning (before htmlspecialchars): <?php $text = preg_replace('/<a/', "\r\n<a", $text); ?> I don't like that but I don't find other solution... :/ ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.135 (proxied: 90.49.213.20) ---- Manual Page -- https://php.net/manual/en/function.htmlspecialchars.php Edit -- https://main.php.net/note/edit/126931 Del: integrated -- https://main.php.net/note/delete/126931/integrated Del: useless -- https://main.php.net/note/delete/126931/useless Del: bad code -- https://main.php.net/note/delete/126931/bad+code Del: spam -- https://main.php.net/note/delete/126931/spam Del: non-english -- https://main.php.net/note/delete/126931/non-english Del: in docs -- https://main.php.net/note/delete/126931/in+docs Del: other reasons-- https://main.php.net/note/delete/126931 Reject -- https://main.php.net/note/reject/126931 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217729) next »