Skip to content

Commit 405b38b

Browse files
committed
Changeset linking regex should not match empty repo
The regex now checks that the 1st char of the repository name is not whitespace. This avoids situations where a string like 'commit: c:repo:sha:' is not matched properly because it is parsed as repo = ' c', and changeset id = 'repo'. Also improve the PHPDoc for CHANGESET_LINKING_REGEX. Fixes #161
1 parent e638ff7 commit 405b38b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Source/Source.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ class SourcePlugin extends MantisPlugin {
1414
static $cache = array();
1515

1616
/**
17-
* Changeset link matching pattern
17+
* Changeset link matching pattern.
1818
* format: '<type>:<reponame>:<revision>:', where
1919
* <type> = link type, 'c' or 's' for changeset details, 'd' or 'v' for diff
20+
* the type may be omitted; if unspecified, defaults to 'c'
2021
* <repo> = repository name
2122
* <rev> = changeset revision ID (e.g. SVN rev number, GIT SHA, etc.)
23+
* The match is not case-sensitive.
2224
*/
23-
const CHANGESET_LINKING_REGEX = '/(?:([cdsv]?):([^:\n\t]+):([^:\n\t\s]+):)/i';
25+
const CHANGESET_LINKING_REGEX = '/(?:([cdsv]?):([^:\s][^:\n\t]*):([^:\s]+):)/i';
2426

2527
function register() {
2628
$this->name = plugin_lang_get( 'title' );

0 commit comments

Comments
 (0)