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

Closes #53: Wysiwyg links #73

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
Fix: [ bug Dolibarr#1707 ] Links appears as raw HTML in calendar events
  • Loading branch information
marcosgdf committed Mar 31, 2015
commit 62aa365c5fd2e25b7dd633294f59df2f7959e280
23 changes: 5 additions & 18 deletions htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3872,6 +3872,7 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8',$removelasteolbr=1)
{
$newstring=$stringtoencode;

if (dol_textishtml($stringtoencode)) // Check if text is already HTML or not
{
$newstring=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
Expand Down Expand Up @@ -4050,26 +4051,12 @@ function dol_microtime_float()
*/
function dol_textishtml($msg,$option=0)
{
if ($option == 1)
{
if (preg_match('/<html/i',$msg)) return true;
elseif (preg_match('/<body/i',$msg)) return true;
elseif (preg_match('/<br/i',$msg)) return true;
return false;
}
else
{
if (preg_match('/<html/i',$msg)) return true;
elseif (preg_match('/<body/i',$msg)) return true;
elseif (preg_match('/<(b|em|i)>/i',$msg)) return true;
elseif (preg_match('/<(br|div|font|img|li|span|strong|table)>/i',$msg)) return true;
elseif (preg_match('/<(br|div|font|img|li|span|strong|table)\s+[^<>\/]*>/i',$msg)) return true;
elseif (preg_match('/<(br|div|font|img|li|span|strong|table)\s+[^<>\/]*\/>/i',$msg)) return true;
elseif (preg_match('/<h[0-9]>/i',$msg)) return true;
elseif (preg_match('/&[A-Z0-9]{1,6};/i',$msg)) return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
elseif (preg_match('/&#[0-9]{2,3};/i',$msg)) return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
//http://stackoverflow.com/questions/5732758/detect-html-tags-in-a-string
if ($msg == strip_tags($msg)) {
return false;
}

return true;
}

/**
Expand Down