FIX #8483
This commit is contained in:
parent
f3e1581ba0
commit
956fc2376d
@ -2323,8 +2323,8 @@ class Adherent extends CommonObject
|
||||
if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
|
||||
if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
|
||||
if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
|
||||
if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 0, 'UTF-8', 1);
|
||||
if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = dol_string_nohtmltag($this->note_public, 0, 'UTF-8', 1);
|
||||
if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
|
||||
if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = dol_string_nohtmltag($this->note_public, 2);
|
||||
if ($this->birth && ! empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth,'dayhourldap');
|
||||
if (isset($this->statut) && ! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
|
||||
if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap');
|
||||
|
||||
@ -530,7 +530,7 @@ class Contact extends CommonObject
|
||||
if ($this->phone_mobile && ! empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile;
|
||||
if ($this->fax && ! empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax;
|
||||
if ($this->skype && ! empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype;
|
||||
if ($this->note_private && ! empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = $this->note_private;
|
||||
if ($this->note_private && ! empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
|
||||
if ($this->email && ! empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email;
|
||||
|
||||
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
|
||||
|
||||
@ -5408,26 +5408,27 @@ function picto_required()
|
||||
/**
|
||||
* Clean a string from all HTML tags and entities.
|
||||
* This function differs from strip_tags because:
|
||||
* - <br> are replace with \n
|
||||
* - if entities are found, they are decoded before the strip
|
||||
* - you can decide to convert line feed into spaces
|
||||
* - <br> are replaced with \n if removelinefeed=0 or 1
|
||||
* - if entities are found, they are decoded BEFORE the strip
|
||||
* - you can decide to convert line feed into a space
|
||||
*
|
||||
* @param string $stringtoclean String to clean
|
||||
* @param integer $removelinefeed 1=Replace also new lines by a space, 0=Only last one are removed
|
||||
* @param integer $removelinefeed 1=Replace all new lines by 1 space, 0=Only ending new lines are removed others are replaced with \n, 2=Ending new lines are removed but others are kept with a same number of \n than nb of <br> when there is both "...<br>\n..."
|
||||
* @param string $pagecodeto Encoding of input/output string
|
||||
* @param integer $strip_tags 1=Use strip_tags php function, 0=Use internal pattern
|
||||
* @param integer $strip_tags 0=Use internal strip, 1=Use strip_tags() php function (bugged when text contains a < char that is not for a html tag)
|
||||
* @return string String cleaned
|
||||
*
|
||||
* @see dol_escape_htmltag strip_tags
|
||||
*/
|
||||
function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF-8',$strip_tags=0)
|
||||
function dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0)
|
||||
{
|
||||
if ($removelinefeed == 2) $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean);
|
||||
$temp = preg_replace('/<br[^>]*>/i', "\n", $stringtoclean);
|
||||
|
||||
if ($strip_tags) {
|
||||
$temp = strip_tags($stringtoclean);
|
||||
$temp = strip_tags($temp);
|
||||
} else {
|
||||
$pattern = "/<[^<>]+>/";
|
||||
$temp = preg_replace('/<br[^>]*>/', "\n", $stringtoclean);
|
||||
|
||||
// Exemple of $temp: <a href="/myurl" title="<u>A title</u>">0000-021</a>
|
||||
$temp = preg_replace($pattern,"",$temp); // pass 1
|
||||
// $temp after pass 1: <a href="/myurl" title="A title">0000-021
|
||||
@ -5438,7 +5439,7 @@ function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF-
|
||||
$temp = dol_html_entity_decode($temp,ENT_COMPAT,$pagecodeto);
|
||||
|
||||
// Supprime aussi les retours
|
||||
if ($removelinefeed) $temp=str_replace(array("\r\n","\r","\n")," ",$temp);
|
||||
if ($removelinefeed == 1) $temp=str_replace(array("\r\n","\r","\n")," ",$temp);
|
||||
|
||||
// et les espaces doubles
|
||||
while (strpos($temp," "))
|
||||
|
||||
@ -2408,7 +2408,7 @@ class User extends CommonObject
|
||||
if ($this->address && ! empty($conf->global->LDAP_FIELD_ADDRESS)) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address;
|
||||
if ($this->zip && ! empty($conf->global->LDAP_FIELD_ZIP)) $info[$conf->global->LDAP_FIELD_ZIP] = $this->zip;
|
||||
if ($this->town && ! empty($conf->global->LDAP_FIELD_TOWN)) $info[$conf->global->LDAP_FIELD_TOWN] = $this->town;
|
||||
if ($this->note_public && ! empty($conf->global->LDAP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_public, 0, 'UTF-8', 1);
|
||||
if ($this->note_public && ! empty($conf->global->LDAP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_public, 2);
|
||||
if ($this->socid > 0)
|
||||
{
|
||||
$soc = new Societe($this->db);
|
||||
|
||||
@ -908,7 +908,7 @@ class UserGroup extends CommonObject
|
||||
// Champs
|
||||
if ($this->name && ! empty($conf->global->LDAP_GROUP_FIELD_FULLNAME)) $info[$conf->global->LDAP_GROUP_FIELD_FULLNAME] = $this->name;
|
||||
//if ($this->name && ! empty($conf->global->LDAP_GROUP_FIELD_NAME)) $info[$conf->global->LDAP_GROUP_FIELD_NAME] = $this->name;
|
||||
if ($this->note && ! empty($conf->global->LDAP_GROUP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1);
|
||||
if ($this->note && ! empty($conf->global->LDAP_GROUP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 2);
|
||||
if (! empty($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS))
|
||||
{
|
||||
$valueofldapfield=array();
|
||||
|
||||
@ -437,17 +437,21 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDolStringNohtmltag()
|
||||
{
|
||||
$text="A\nstring\n";
|
||||
$text="A\nstring\n\nand more\n";
|
||||
$after=dol_string_nohtmltag($text,0);
|
||||
$this->assertEquals("A\nstring",$after,"test1");
|
||||
$this->assertEquals("A\nstring\n\nand more",$after,"test1a");
|
||||
|
||||
$text="A <b>string<b>\n\nwith html tag and '<' chars<br>\n";
|
||||
$text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
|
||||
$after=dol_string_nohtmltag($text, 0);
|
||||
$this->assertEquals("A string\n\nwith html tag and '<' chars",$after,"test2");
|
||||
$this->assertEquals("A string\n\n\n\n\nwith html tag",$after,"test2a 2 br and 3 \n give 5 \n");
|
||||
|
||||
$text="A <b>string<b>\n\nwith tag with < chars<br>\n";
|
||||
$text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
|
||||
$after=dol_string_nohtmltag($text, 1);
|
||||
$this->assertEquals("A string with tag with < chars",$after,"test3");
|
||||
$this->assertEquals("A string with html tag",$after,"test2b 2 br and 3 \n give 1 space");
|
||||
|
||||
$text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
|
||||
$after=dol_string_nohtmltag($text, 2);
|
||||
$this->assertEquals("A string\n\nwith html tag",$after,"test2c 2 br and 3 \n give 2 \n");
|
||||
|
||||
$text="A string<br>Another string";
|
||||
$after=dol_string_nohtmltag($text,0);
|
||||
@ -469,6 +473,14 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
$after=dol_string_nohtmltag($text,0);
|
||||
$this->assertEquals("HIJ",$after,"test8");
|
||||
|
||||
$text="A <b>string<b>\n\nwith html tag and '<' chars<br>\n";
|
||||
$after=dol_string_nohtmltag($text, 0);
|
||||
$this->assertEquals("A string\n\nwith html tag and '<' chars",$after,"test9");
|
||||
|
||||
$text="A <b>string<b>\n\nwith tag with < chars<br>\n";
|
||||
$after=dol_string_nohtmltag($text, 1);
|
||||
$this->assertEquals("A string with tag with < chars",$after,"test10");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -830,7 +842,7 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$s=img_picto('title', 'delete', '', 0, 1);
|
||||
print __METHOD__." s=".$s."\n";
|
||||
$this->assertEquals('/theme/eldy/img/delete.png',$s,'testImgPicto5');
|
||||
$this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png',$s,'testImgPicto5');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user