diff --git a/web/plugins/buildrepository/commitutils.php b/web/plugins/buildrepository/commitutils.php index 88cdf6d061..92e175246c 100644 --- a/web/plugins/buildrepository/commitutils.php +++ b/web/plugins/buildrepository/commitutils.php @@ -22,6 +22,7 @@ includeGuard('commitutils.php'); require_once(DIR_INCLUDES.'/utilities.inc.php'); +require_once(DIR_CLASSES.'/url.class.php'); require_once('buildevent.class.php'); function addCommitToGroup(&$groups, $groupName, &$commit) @@ -67,18 +68,36 @@ function groupBuildCommits(&$build, &$groups) function make_pretty_hyperlink($matches) { - $uri = implode('', array_slice($matches, 1)); - return generateHyperlinkHTML($uri, 40, 'link-external'); + global $FrontController; + + $uri = new Url(implode('', array_slice($matches, 1))); + $homeUri = new Url($FrontController->homeURL()); + + $isExternal = ($uri->host() !== $homeUri->host()); + if(!$isExternal) + { + $uri->setScheme()->setHost(); + } + + return generateHyperlinkHTML($uri, 40, $isExternal? 'link-external' : NULL); } -function formatCommitMessageHTML($msg) +function formatCommitHTML($msg) { if(strcasecmp(gettype($msg), 'string')) return $msg; // Process the commit message, replacing web URIs with clickable links. htmlspecialchars($msg); - $msg = preg_replace_callback("/([^A-z0-9])(http|ftp|https)([\:\/\/])([^\\s]+)/", + $msg = preg_replace_callback("/([^A-z0-9_])(http|ftp|https)([\:\/\/])([^\\s]+)/", "make_pretty_hyperlink", $msg); + return $msg; +} + +function formatCommitMessageHTML($msg) +{ + if(strcasecmp(gettype($msg), 'string')) return $msg; + + $msg = formatCommitHTML($msg); $msg = nl2br($msg); return $msg; } @@ -89,6 +108,7 @@ function outputCommitHTML(&$commit) throw new Exception('Invalid commit argument, array expected'); // Format the commit message for HTML output. + $title = formatCommitHTML($commit['title']); $message = formatCommitMessageHTML($commit['message']); $haveMessage = (bool)(strlen($message) > 0); @@ -116,7 +136,7 @@ function outputCommitHTML(&$commit) // Ouput HTML for the commit. ?>

> by

> by