Relationship Graph

Relationship Graph
related to related to child of child of duplicate of duplicate of

View Issue Details

IDProjectCategoryView StatusLast Update
0007790mantisbtbugtrackerpublic2009-06-23 15:28
Reporterexk72 Assigned Tojreese  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformPCOSWindows XPOS Version5.1
Product Versiongit trunk 
Target Version1.2.0rc1Fixed in Version1.2.0rc1 
Summary0007790: Links protected by brackets are not processed properly
Description

Same as the closed bug 0004326

Tagsurl, usability
Attached Files
7790.patch (1,229 bytes)   
Index: core/string_api.php
===================================================================
--- core/string_api.php	(revision 5752)
+++ core/string_api.php	(working copy)
@@ -411,13 +411,26 @@
 # --------------------
 # Detect href anchors in the string and replace them with URLs and email addresses
 function string_strip_hrefs( $p_string ) {
-
 	# First grab mailto: hrefs.  We don't care whether the URL is actually
 	# correct - just that it's inside an href attribute.
 	$p_string = preg_replace( '/<a\s[^\>]*href="mailto:([^\"]+)"[^\>]*>[^\<]*<\/a>/si', '\1', $p_string );
 
 	# Then grab any other href
 	$p_string = preg_replace( '/<a\s[^\>]*href="([^\"]+)"[^\>]*>[^\<]*<\/a>/si', '\1', $p_string );
+	//EC RH http://www.mantisbt.org/bugs/view.php?id=7790
+	if(strstr($p_string, '(')){
+		if(strstr($p_string, '(http://')) {
+			$start = strpos($p_string, '(http://'); $tmp =  substr($p_string, $start, strlen($p_string));
+			$lnt = strpos($tmp, ' ');$stop = $start + $lnt; 
+			$tmp =  substr($p_string, $start, $lnt);
+			$h = strripos($tmp,'(');
+			if($h == 0){
+				$p_string = str_replace('(', '', $p_string);
+				$p_string = str_replace(')', '', $p_string);
+			}
+		}
+	}
+	//EC RH
 	return $p_string;
 }
 
7790.patch (1,229 bytes)   

Relationships

related to 0008814 closedjreese problem posting FTP access string 

Activities

klkl

klkl

2009-01-13 06:30

reporter   ~0020601

Last edited: 2009-01-13 06:30

Same with parens, e.g.: (http://www.mantisbt.org/bugs/view.php?id=4326)

jreese

jreese

2009-01-13 10:53

reporter   ~0020604

Targetting for 1.2.x - fix should be contained to string_api.php.

jreese

jreese

2009-01-13 10:55

reporter   ~0020605

The real trouble with this "bug" is that parenthesis and bracket characters are perfectly valid as part of well-formed URLs. However, it might be possible to add some sort of "simple" regex to pull out and discard pairs of parens or brackets from right around a URL...

klkl

klkl

2009-01-13 11:12

reporter   ~0020608

My suggestion is to include closing parenthesis in URL only if it has matching opening parenthesis, e.g.

")" linked: http://en.wikipedia.org/wiki/Mantis_(disambiguation)

")" not linked: http://en.wikipedia.org/wiki/Mantis_Bug_Tracker)

rhurtik

rhurtik

2009-01-22 06:35

reporter   ~0020683

Attached patch "7790.patch" strip off the parentheses in the case they are not part of the url. The fix doesn't affect links like http://en.wikipedia.org/wiki/Mantis_(disambiguation) .

jreese

jreese

2009-01-27 12:27

reporter   ~0020728

Fix committed to 1.2.x development tree.

Related Changesets

MantisBT: master 3e893655

2009-01-27 11:56

jreese


Details Diff
Fix 0007790: change URL-parsing regex to 'better' handle parentheses and brackets in and at the end of URL's, without gobbling up parentheses and brackets surrounding the URL. Affected Issues
0007790
mod - core/string_api.php Diff File