From 8276a2a4488d3a716983429ed35c590f37636ece Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Sat, 18 Jan 2014 17:02:29 +0000 Subject: [PATCH] fix for problem with style fragments on triggering mail compose build in html validation --- phpgwapi/inc/class.egw_htmLawed.inc.php | 8 +++- phpgwapi/inc/class.html.inc.php | 59 ++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/phpgwapi/inc/class.egw_htmLawed.inc.php b/phpgwapi/inc/class.egw_htmLawed.inc.php index 0c7deb427d..e0db51a809 100644 --- a/phpgwapi/inc/class.egw_htmLawed.inc.php +++ b/phpgwapi/inc/class.egw_htmLawed.inc.php @@ -108,8 +108,14 @@ class egw_htmLawed if (is_array($Config) && is_array($this->Configuration)) $Config = array_merge($this->Configuration, $Config); if (empty($Config)) $Config = $this->Configuration; if (empty($Spec)) $Spec = $this->Spec; + // If we are processing mails, we take out stuff in tags and + // put it back in after purifying; styles are processed for known security risks + // in html::getStyles + $styles=''; + if ($Config['hook_tag'] =="hl_email_tag_transform") $styles = html::getStyles($html2check); + //error_log(__METHOD__.__LINE__.array2string($styles)); - return htmLawed($html2check, $Config, $Spec); + return ($styles?$styles:'').htmLawed($html2check, $Config, $Spec); } } diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index e83d60d7ea..9e79896be9 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -178,17 +178,22 @@ class html $Domain = '([\w-]+\.[\w-.]+)'; $Subdir = '([\w\-\.,@?^=%&;:\/~\+#]*[\w\-\@?^=%&\/~\+#])?'; $optBracket = ''; + //$optBracket = '(>|>)'; $Expr = '/' . $NotAnchor . $Protocol . $Domain . $Subdir . $optBracket . '/i'; $result = preg_replace( $Expr, "$2$3$4", $result ); + //$result = preg_replace( $Expr, "$2$3$4$5 ", $result ); // Now match things beginning with www. $NotHTTP = '(?)'; // avoid running again on http://www links already handled above $Domain = 'www(\.[\w-.]+)'; $Subdir = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?'; $Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . '/i'; + //$optBracket = '(>|>)'; + //$Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . $optBracket . '/i'; return preg_replace( $Expr, "$0", $result ); + //return preg_replace( $Expr, "www$1$2$3 ", $result ); } /** @@ -489,7 +494,7 @@ class html // 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 doublecheck availability for us, but its fallback does not look nice, and you will get + // CKeditor 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; } @@ -554,6 +559,7 @@ class html // we need to enable double encoding here, as ckEditor has to undo one level of encoding // otherwise < and > chars eg. from html markup entered in regular (not source) input, will turn into html! + //error_log(__METHOD__.__LINE__.' '.self::$user_agent.','.self::$ua_version); return self::textarea($_name,$_content,'id="'.htmlspecialchars($_name).'"',true). // true = double encoding '