Skip to content

Commit 647f41c

Browse files
committed
Merge remote-tracking branch 'origin/master'
Conflicts: Source/MantisSourceBase.class.php SourceCgit/SourceCgit.php SourceGithub/SourceGithub.php SourceGitlab/SourceGitlab.php SourceGitphp/SourceGitphp.php SourceGitweb/SourceGitweb.php
2 parents 682de55 + 3c30d6d commit 647f41c

25 files changed

+399
-59
lines changed

README.md

100755100644
File mode changed.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
3+
# Copyright (c) 2017 Damien Regad
4+
# Licensed under the MIT license
5+
6+
require_once( 'MantisSourcePlugin.class.php' );
7+
8+
/**
9+
* Class MantisSourceGitBasePlugin
10+
*
11+
* Base class providing common methods for all git-based Source Integration
12+
* Plugin classes.
13+
*
14+
*/
15+
abstract class MantisSourceGitBasePlugin extends MantisSourcePlugin
16+
{
17+
/**
18+
* Git branch name validation regex.
19+
* Based on rules defined in man page
20+
* http://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
21+
*/
22+
private $valid_branch_regex = '%'
23+
# Must not start with '/'; cannot contain '/.', '//', '@{' or '\';
24+
# cannot be a single '@'.
25+
. '^(?!/|.*([/.]\.|//|@\{|\\\\)|@$)'
26+
# One or more chars, except the following: ASCII control, space,
27+
# tilde, caret, colon, question mark, asterisk, open bracket.
28+
. '[^\000-\037\177 ~^:?*[]+'
29+
# Must not end with '.lock', '/' or '.'
30+
. '(?<!\.lock|[/.])$'
31+
. '%';
32+
33+
/**
34+
* Error constants
35+
*/
36+
const ERROR_INVALID_BRANCH = 'invalid_branch';
37+
38+
/**
39+
* Define plugin's Error strings
40+
* @return array
41+
*/
42+
public function errors() {
43+
$t_errors_list = array(
44+
self::ERROR_INVALID_BRANCH,
45+
);
46+
47+
foreach( $t_errors_list as $t_error ) {
48+
$t_errors[$t_error] = plugin_lang_get( 'error_' . $t_error, 'Source' );
49+
}
50+
51+
return $t_errors;
52+
}
53+
54+
/**
55+
* Determines if given string name is a valid git branch name.
56+
* @param string $p_branch Branch name to validate
57+
* @return bool True if valid
58+
*/
59+
protected function is_branch_valid( $p_branch )
60+
{
61+
return (bool)preg_match( $this->valid_branch_regex, $p_branch );
62+
}
63+
64+
/**
65+
* Triggers an error if the branch is invalid
66+
* @param string $p_branch Branch name to validate
67+
* @return void
68+
*/
69+
protected function ensure_branch_valid( $p_branch )
70+
{
71+
if( !$this->is_branch_valid( $p_branch ) ) {
72+
error_parameters( $p_branch );
73+
plugin_error( self::ERROR_INVALID_BRANCH );
74+
}
75+
}
76+
77+
/**
78+
* Validates a comma-delimited list of git branches.
79+
* Triggers an ERROR_INVALID_BRANCH if one of the branches is invalid
80+
* @param string $p_list Comma-delimited list of branch names (or '*')
81+
* @return void
82+
*/
83+
protected function validate_branch_list( $p_list )
84+
{
85+
if( $p_list == '*' ) {
86+
return;
87+
}
88+
89+
foreach( explode( ',', $p_list ) as $t_branch ) {
90+
$this->ensure_branch_valid( trim( $t_branch ) );
91+
}
92+
}
93+
}

Source/Source.API.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ function save() {
927927
db_param() . ', ' . db_param() . ' )';
928928
db_query( $t_query, array(
929929
$this->repo_id, $this->revision, $this->parent, $this->branch,
930-
$this->user_id, $this->timestamp, $this->author, $this->message, $this->info,
930+
$this->user_id, $this->timestamp, $this->author, db_mysql_fix_utf8( $this->message ), $this->info,
931931
$this->ported, $this->author_email, $this->committer, $this->committer_email,
932932
$this->committer_id ) );
933933

Source/Source.php

100755100644
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class SourcePlugin extends MantisSourceBase {
1313

1414
static $cache = array();
1515

16+
const PLUGIN_VERSION = self::FRAMEWORK_VERSION;
17+
1618
/**
1719
* Changeset link matching pattern.
1820
* format: '<type>:<reponame>:<revision>:', where
@@ -28,7 +30,7 @@ function register() {
2830
$this->name = plugin_lang_get( 'title' );
2931
$this->description = plugin_lang_get( 'description' );
3032

31-
$this->version = self::FRAMEWORK_VERSION;
33+
$this->version = self::PLUGIN_VERSION;
3234
$this->requires = array(
3335
'MantisCore' => self::MANTIS_VERSION,
3436
);

Source/lang/strings_english.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,4 @@ $s_plugin_Source_import_full_failed = 'Full repository data importing failed.';
147147

148148
$s_plugin_Source_changeset_column_title = 'C';
149149

150+
$s_plugin_Source_error_invalid_branch = 'Invalid characters in Branch name "%1$s".';

Source/lang/strings_german.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,5 @@ $s_plugin_Source_import_latest_failed = 'Partieller Import des Projektarchivs fe
144144
$s_plugin_Source_import_full_failed = 'Vollständiger Import des Projektarchivs fehlgeschlagen.';
145145

146146
$s_plugin_Source_changeset_column_title = 'C';
147+
148+
$s_plugin_Source_error_invalid_branch = 'Ungültige Zeichen in der Zweige "%1$s"';

Source/pages/checkin.php

100755100644
File mode changed.

Source/pages/manage_config.php

100755100644
File mode changed.

Source/pages/manage_config_page.php

100755100644
File mode changed.

SourceBitBucket/SourceBitBucket.php

100755100644
File mode changed.

0 commit comments

Comments
 (0)