Try to fix a lot of regression. Add also more phpunit test to avoid them in future.

This commit is contained in:
Laurent Destailleur
2011-05-01 20:53:46 +00:00
parent a0c141294f
commit 0053ecdab9
5 changed files with 20 additions and 23 deletions

View File

@@ -81,8 +81,11 @@ class DolEditor
{ {
$this->tool = 'textarea'; $this->tool = 'textarea';
} }
if ($this->tool == 'ckeditor')
if ($this->tool == 'fckeditor') {
$content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML.
}
if ($this->tool == 'fckeditor')
{ {
require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php"); require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php");

View File

@@ -312,7 +312,8 @@ function dol_string_nospecial($str,$newstr='_',$badchars='')
function dol_escape_js($stringtoescape) function dol_escape_js($stringtoescape)
{ {
// escape quotes and backslashes, newlines, etc. // escape quotes and backslashes, newlines, etc.
return strtr($stringtoescape, array("&#039;"=>"\\'",'\\'=>'\\\\',"'"=>"\\'",'"'=>"\\'","\r"=>'\\r',"\n"=>'\\n','</'=>'<\/')); $substitjs=array("&#039;"=>"\\'",'\\'=>'\\\\',"'"=>"\\'",'"'=>"\\'","\r"=>'\\r',"\n"=>'\\n','</'=>'<\/');
return strtr($stringtoescape, $substitjs);
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
@@ -1082,7 +1082,7 @@ if ($id || $ref)
print '<tr><td>'.$html->editfieldkey("ProductAccountancySellCode",'productaccountancycodesell',$product->accountancy_code_sell,'id',$product->id,$user->rights->produit->creer).'</td><td colspan="2">'; print '<tr><td>'.$html->editfieldkey("ProductAccountancySellCode",'productaccountancycodesell',$product->accountancy_code_sell,'id',$product->id,$user->rights->produit->creer).'</td><td colspan="2">';
print $html->editfieldval("ProductAccountancySellCode",'productaccountancycodesell',$product->accountancy_code_sell,'id',$product->id,$user->rights->produit->creer); print $html->editfieldval("ProductAccountancySellCode",'productaccountancycodesell',$product->accountancy_code_sell,'id',$product->id,$user->rights->produit->creer);
print '</td></tr>'; print '</td></tr>';
// Accountancy buy code // Accountancy buy code
print '<tr><td>'.$html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodebuy',$product->accountancy_code_buy,'id',$product->id,$user->rights->produit->creer).'</td><td colspan="2">'; print '<tr><td>'.$html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodebuy',$product->accountancy_code_buy,'id',$product->id,$user->rights->produit->creer).'</td><td colspan="2">';
print $html->editfieldval("ProductAccountancyBuyCode",'productaccountancycodebuy',$product->accountancy_code_buy,'id',$product->id,$user->rights->produit->creer); print $html->editfieldval("ProductAccountancyBuyCode",'productaccountancycodebuy',$product->accountancy_code_buy,'id',$product->id,$user->rights->produit->creer);
@@ -1099,7 +1099,7 @@ if ($id || $ref)
print '</td></tr>'; print '</td></tr>';
// Description // Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">'.dol_nl2br($product->description,1,true).'</td></tr>'; print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">'.(dol_textishtml($product->description)?$product->description:dol_nl2br($product->description,1,true)).'</td></tr>';
// Nature // Nature
if($product->type!=1) if($product->type!=1)
@@ -1196,7 +1196,7 @@ if ($id || $ref)
*/ */
// Note // Note
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="2">'.nl2br($product->note).'</td></tr>'; print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="2">'.(dol_textishtml($product->note)?$product->note:dol_nl2br($product->note,1,true)).'</td></tr>';
print "</table>\n"; print "</table>\n";
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2003,2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2003,2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* *
@@ -127,7 +127,7 @@ if ($socid > 0)
} }
else else
{ {
print nl2br($societe->note); print dol_textishtml($societe->note)?$societe->note:dol_nl2br($societe->note,1,true);
} }
print "</td></tr>"; print "</td></tr>";

View File

@@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -123,21 +123,14 @@ if ($id)
{ {
print "<input type=\"hidden\" name=\"action\" value=\"update\">"; print "<input type=\"hidden\" name=\"action\" value=\"update\">";
print "<input type=\"hidden\" name=\"id\" value=\"".$fuser->id."\">"; print "<input type=\"hidden\" name=\"id\" value=\"".$fuser->id."\">";
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_USER) // Editeur wysiwyg
{ require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
// Editeur wysiwyg $doleditor=new DolEditor('note',$fuser->note,'',280,'dolibarr_notes','In',true,false,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_USER,10,80);
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); $doleditor->Create();
$doleditor=new DolEditor('note',$fuser->note,'',280,'dolibarr_notes','In',true);
$doleditor->Create();
}
else
{
print '<textarea name="note" cols="80" rows="10">'.dol_htmlentitiesbr_decode($fuser->note).'</textarea>';
}
} }
else else
{ {
print nl2br($fuser->note); print dol_textishtml($fuser->note)?$fuser->note:dol_nl2br($fuser->note,1,true);
} }
print "</td></tr>"; print "</td></tr>";
@@ -162,7 +155,7 @@ if ($id)
if ($user->rights->user->user->creer && $action != 'edit') if ($user->rights->user->user->creer && $action != 'edit')
{ {
print "<a class=\"butAction\" href=\"note.php?id=$fuser->id&amp;action=edit\">".$langs->trans('Modify')."</a>"; print "<a class=\"butAction\" href=\"note.php?id=".$fuser->id."&amp;action=edit\">".$langs->trans('Modify')."</a>";
} }
print "</div>"; print "</div>";