check availaility of htmlarea before opening compose as html or html mails as html for reply; implement check based on http_user_agent for user agent known to be not compliant with ckeditor (android); allow class attribute for div, blockquote, a and img

This commit is contained in:
Klaus Leithoff 2011-10-31 11:00:13 +00:00
parent 0855d84dfb
commit a80521e321
2 changed files with 32 additions and 9 deletions

View File

@ -105,6 +105,11 @@
$formData['signatureID'] = (int)$_POST['signatureID'];
$formData['stationeryID'] = $_POST['stationeryID'];
$formData['mimeType'] = $this->bocompose->stripSlashes($_POST['mimeType']);
if ($formData['mimeType'] == 'html' && html::htmlarea_availible()===false)
{
$formData['mimeType'] = 'plain';
$formData['body'] = $this->bocompose->convertHTMLToText($formData['body']);
}
$formData['disposition'] = (bool)$_POST['disposition'];
$formData['to_infolog'] = $_POST['to_infolog'];
$formData['to_tracker'] = $_POST['to_tracker'];
@ -268,6 +273,12 @@
{
$sessionData['mimeType'] = $_REQUEST['mimeType'];
}
if ($sessionData['mimeType'] == 'html' && html::htmlarea_availible()===false)
{
$sessionData['mimeType'] = 'plain';
$sessionData['body'] = $this->bocompose->convertHTMLToText($sessionData['body']);
}
// is a certain signature requested?
// only the following values are supported (and make sense)
// no => means -2
@ -538,7 +549,14 @@
$this->t->set_var("select_signature", $selectBoxSignature);
$this->t->set_var("select_stationery", ($showStationaries ? $selectBoxStationery:''));
$this->t->set_var("lang_editormode",lang("Editor type"));
$this->t->set_var("toggle_editormode", lang("Editor type").":&nbsp;<span><input name=\"_is_html\" value=\"".$ishtml."\" type=\"hidden\" /><input name=\"_editorselect\" onchange=\"fm_toggle_editor(this)\" ".($ishtml ? "checked=\"checked\"" : "")." id=\"_html\" value=\"html\" type=\"radio\"><label for=\"_html\">HTML</label><input name=\"_editorselect\" onchange=\"fm_toggle_editor(this)\" ".($ishtml ? "" : "checked=\"checked\"")." id=\"_plain\" value=\"plain\" type=\"radio\"><label for=\"_plain\">Plain text</label></span>");
if (html::htmlarea_availible()===false)
{
$this->t->set_var("toggle_editormode",'');
}
else
{
$this->t->set_var("toggle_editormode", lang("Editor type").":&nbsp;<span><input name=\"_is_html\" value=\"".$ishtml."\" type=\"hidden\" /><input name=\"_editorselect\" onchange=\"fm_toggle_editor(this)\" ".($ishtml ? "checked=\"checked\"" : "")." id=\"_html\" value=\"html\" type=\"radio\"><label for=\"_html\">HTML</label><input name=\"_editorselect\" onchange=\"fm_toggle_editor(this)\" ".($ishtml ? "" : "checked=\"checked\"")." id=\"_plain\" value=\"plain\" type=\"radio\"><label for=\"_plain\">Plain text</label></span>");
}
$this->t->pparse("out","body_input");
// attachments

View File

@ -549,12 +549,16 @@ class html
*/
static function htmlarea_availible()
{
/* require_once(EGW_INCLUDE_ROOT.'/phpgwapi/js/fckeditor/fckeditor.php');
//error_log(__METHOD__.__LINE__.' userAgent:'.$_SERVER[HTTP_USER_AGENT]);
// we check for the useragent to be able to recognize andoid machines that do not support ckeditor yet.
// ckeditors fallback is rather unpleaseant.
if (stripos($_SERVER[HTTP_USER_AGENT],'android') !== false) return false;
// use FCKeditor's own check
return FCKeditor_IsCompatibleBrowser();*/
// this one is for testing how it will turn out, if you do not have the device or agent ready at your fingertips
// if (stripos($_SERVER[HTTP_USER_AGENT],'mozilla') !== false) return false;
//CKeditor3 will check availability for us
// CKeditor3 will doublecheck availability for us, but its fallback does not look nice, and you will get
// no conversion of html content to plain text, so we provide a check for known USER_AGENTS to fail the test
return true;
}
@ -1473,18 +1477,19 @@ class html
// enable target attributes
$config->set('Attr.AllowedFrameTargets','_blank,_top,_self,_parent');
// actual allowed tags and attributes
$config->set('HTML.Allowed', 'br,p[align|style],b,i,u,s,em,pre,tt,strong,strike,sub,sup,center,div[align|style],hr[class|style],'.
'ul[type],ol[type|start],li,'.
$config->set('HTML.Allowed', 'br,p[class|align|style],b,i,u,s,em,pre,tt,strong,strike,sub,sup,center,div[class|align|style],hr[class|style],'.
'ul[class|type],ol[class|type|start],li,'.
'h1,h2,h3,h4,h5,h6,'.
'span[class|style],'.
'table[class|border|cellpadding|cellspacing|width|style|align|bgcolor|align],'.
'tbody,thead,tfoot,colgroup,'.
'col[width|span],'.
'col[class|width|span],'.
'blockquote[class|cite|dir],'.
'tr[class|style|align|bgcolor|align|valign],'.
'td[class|colspan|rowspan|width|style|align|bgcolor|align|valign|nowrap],'.
'th[class|colspan|rowspan|width|style|align|bgcolor|align|valign|nowrap],'.
'a[href|target|name|title],img[src|alt|title|align|style|width|height]');
'a[class|href|target|name|title],'.
'img[class|src|alt|title|align|style|width|height]');
$config->set('Cache.SerializerPath', ($GLOBALS['egw_info']['server']['temp_dir']?$GLOBALS['egw_info']['server']['temp_dir']:sys_get_temp_dir()));
}
$purifier = new HTMLPurifier($config);