Bugzilla and htmlify

Yesterday I tweeted that FreshPorts now directs you to bugs.freebsd.org for a PR. I noticed the URL typo but I was headed to bed.

Today, @FreeBSDHelp told me that links involving a category were wrong.

Here’s the patch:

$ svn di -x -u htmlify.php
Index: htmlify.php
===================================================================
--- htmlify.php	(revision 4632)
+++ htmlify.php	(working copy)
@@ -25,9 +25,9 @@
 
 
 function pr2link($Arr) {
-	return preg_replace("/((\w+\/)?\d+)/", 
-					"<A HREF=\"http://bugs.FreeBSD.org/\\1\">\\1</A>",
-					$Arr[0]);  
+	return preg_replace("/(\w+\/)?(\d+)/", 
+			    "<a href=\"http://bugs.FreeBSD.org/\\2\">\\1\\2</a>",
+			    $Arr[0]);  
 }
 
 function mail2link($Arr) {
@@ -96,7 +96,7 @@
 	$String = preg_replace_callback("/(<a href=(\"|')(http|ftp|https):\/\/.*?)(\">|'>)(.*?)<\/a>/i", 'url_shorten', $String);
 	$String = preg_replace_callback("/([\w+=\-.!]+@[\w\-]+(\.[\w\-]+)+)/",                           'mail2link',   $String);
 	if ($Process_PRs) {
-		$String = preg_replace_callback("/\bPR[:\#]?\s*(\d+)([,\s\n]*(\d+))*/",                      'pr2link',     $String);
+		$String = preg_replace_callback("/\bPR[:\#]?\s*(\d+)([,\s\nand]*(\d+))*/",                      'pr2link',     $String);
 		$String = preg_replace_callback("/[\w\s]+((advocacy|alpha|bin|conf|docs|gnu|i386|ia64|java|kern|misc|ports|powerpc|sparc64|standards|www)\/\d+)/", 'pr2link', $String);
 	}
 

The first half fixed the case for ports/1234 etc. The second half fixes: PR 1234, 123, and 1234

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top