[eGroupWare-svn] r55972 - /branches/14.2/phpgwapi/inc/class.html.inc.php

[email protected] Mon, 02 May 2016 12:15:14 -0000
Newsgroups gmane.comp.web.egroupware.cvs
Message-ID <[email protected]>
Author: leithoff
Date: Mon May  2 14:15:14 2016
New Revision: 55972

URL: http://svn.stylite.de/viewvc/egroupware?rev=55972&view=rev
Log:
handle doublequotes that may enclose URLs

Modified:
    branches/14.2/phpgwapi/inc/class.html.inc.php

Modified: branches/14.2/phpgwapi/inc/class.html.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/branches/14.2/phpgwapi/inc/class.html.inc.php?rev=55972&r1=55971&r2=55972&view=diff
==============================================================================
--- branches/14.2/phpgwapi/inc/class.html.inc.php (original)
+++ branches/14.2/phpgwapi/inc/class.html.inc.php Mon May  2 14:15:14 2016
@@ -222,11 +222,29 @@
 		$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';	// only http:// gets removed, other protocolls are shown
 		$Domain = '([\w-]+\.[\w-.]+)';
 		$Subdir = '([\w\-\.,@?^=%&;:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
-		$Expr = '/' . $NotAnchor . $Protocol . $Domain . $Subdir . '/i';
+		$optStuff = '(&quot;|&quot|;)?';
+		$Expr = '/' . $NotAnchor . $Protocol . $Domain . $Subdir . $optStuff . '/i';
 		// use preg_replace_callback as we experienced problems with https links
 		$result3 = preg_replace_callback( $Expr, function ($match) {
+				$additionalQuote="";//at the end, ...
+				// only one &quot at the end is found. chance is, it is not belonging to the URL
+				if ($match[5]==';' && (strlen($match[4])-6) >=0 && strpos($match[4],'&quot',strlen($match[4])-6)!==false && strpos(substr($match[4],0,strlen($match[4])-6),'&quot')===false)
+				{
+					$match[4] = substr($match[4],0,strpos($match[4],'&quot',strlen($match[4])-6));
+					$additionalQuote = "&quot;";
+				}
+				// if there is quoted stuff within the URL then we have at least one more &quot; in match[4], so chance is the last &quot is matched by the one within
+				if ($match[5]==';' && (strlen($match[4])-6) >=0 && strpos($match[4],'&quot',strlen($match[4])-6)!==false && strpos(substr($match[4],0,strlen($match[4])-6),'&quot')!==false)
+				{
+					$match[4] .= $match[5];
+				}
+				if ($match[5]==';'&&$match[4]=="&quot")
+				{
+					$match[4] ='';
+					$additionalQuote = "&quot;";
+				}
 				//error_log(__METHOD__.__LINE__.array2string($match));
-				return "<a href=\"".($match[1]&&!$match[2]?$match[1]:'').($match[2]?$match[2]:'').$match[3].$match[4]."\" target=\"_blank\">".$match[3].$match[4]."</a>";
+				return "<a href=\"".($match[1]&&!$match[2]?$match[1]:'').($match[2]?$match[2]:'').$match[3].$match[4]."\" target=\"_blank\">".$match[3].$match[4]."</a>$additionalQuote";
 			}, $result2 );
 //error_log(__METHOD__.__LINE__.array2string($Expr));
 //error_log(__METHOD__.__LINE__.array2string($result3));


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z