From adc4c9ad98099dccbb6623e97086738850cd6119 Mon Sep 17 00:00:00 2001 From: liyuchun Date: Fri, 31 Dec 2021 10:23:49 +0800 Subject: [PATCH] * Fix bug #18088. --- config/filter.php | 2 +- module/gitlab/control.php | 22 +++++++++++--------- module/gitlab/view/browsebranchpriv.html.php | 6 ++++-- module/gitlab/view/browsetag.html.php | 4 +++- module/gitlab/view/browsetagpriv.html.php | 6 ++++-- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/config/filter.php b/config/filter.php index b0215c07eb..9802fd1122 100644 --- a/config/filter.php +++ b/config/filter.php @@ -11,7 +11,7 @@ $filter->rules->orderBy = '/^\w+_(desc|asc)$/i'; $filter->rules->browseType = '/^by\w+$/i'; $filter->rules->word = '/^\w+$/'; $filter->rules->paramName = '/^[a-zA-Z0-9_\.]+$/'; -$filter->rules->paramValue = '/^[a-zA-Z0-9=_,`#+\^\/\.%\|\x7f-\xff\-]+$/'; +$filter->rules->paramValue = '/^[a-zA-Z0-9=_,`#+\^\/\.%\*\|\x7f-\xff\-]+$/'; $filter->default = new stdclass(); $filter->default->moduleName = 'code'; diff --git a/module/gitlab/control.php b/module/gitlab/control.php index b46e87bae5..566b422a9d 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -845,7 +845,9 @@ class gitlab extends control */ public function createBranchPriv($gitlabID, $projectID, $branch = '') { - if($branch) $branch = helper::safe64Decode($branch); + /* Fix error when request type is PATH_INFO and the branch name contains '-'.*/ + if($branch) $branch = str_replace('*', '-', $branch); + if($_POST) { $this->gitlab->createBranchPriv($gitlabID, $projectID, $branch); @@ -921,7 +923,8 @@ class gitlab extends control die(js::confirm($this->lang->gitlab->branch->confirmDelete , inlink('deleteBranchPriv', "gitlabID=$gitlabID&projectID=$projectID&branch=$branch&confirm=yes"))); } - $branch = helper::safe64Decode($branch); + /* Fix error when request type is PATH_INFO and the branch name contains '-'.*/ + $branch = str_replace('*', '-', $branch); $reponse = $this->gitlab->apiDeleteBranchPriv($gitlabID, $projectID, $branch); /* If the status code beginning with 20 is returned or empty is returned, it is successful. */ @@ -1096,7 +1099,8 @@ class gitlab extends control */ public function editTagPriv($gitlabID, $projectID, $tag = '') { - $tag = helper::safe64Decode($tag); + /* Fix error when request type is PATH_INFO and the tag name contains '-'.*/ + $tag = str_replace('*', '-', $tag); if($_POST) { @@ -1128,7 +1132,8 @@ class gitlab extends control */ public function deleteTagPriv($gitlabID, $projectID, $tag) { - $tag = helper::safe64Decode($tag); + /* Fix error when request type is PATH_INFO and the tag name contains '-'.*/ + $tag = str_replace('*', '-', $tag); $reponse = $this->gitlab->apiDeleteTagPriv($gitlabID, $projectID, $tag); /* If the status code beginning with 20 is returned or empty is returned, it is successful. */ @@ -1537,13 +1542,10 @@ class gitlab extends control */ public function deleteTag($gitlabID, $projectID, $tagName = '', $confirm = 'no') { - if($confirm != 'yes') - { - $tagName = urlencode($tagName); - die(js::confirm($this->lang->gitlab->tag->confirmDelete , inlink('deleteTag', "gitlabID=$gitlabID&projectID=$projectID&tagName=$tagName&confirm=yes"))); - } + if($confirm != 'yes') die(js::confirm($this->lang->gitlab->tag->confirmDelete , inlink('deleteTag', "gitlabID=$gitlabID&projectID=$projectID&tagName=$tagName&confirm=yes"))); - $tagName = helper::safe64Decode($tagName); + /* Fix error when request type is PATH_INFO and the tag name contains '-'.*/ + $tagName = str_replace('*', '-', $tagName); $reponse = $this->gitlab->apiDeleteTag($gitlabID, $projectID, $tagName); /* If the status code beginning with 20 is returned or empty is returned, it is successful. */ diff --git a/module/gitlab/view/browsebranchpriv.html.php b/module/gitlab/view/browsebranchpriv.html.php index c99a16c434..eb873d3e3d 100644 --- a/module/gitlab/view/browsebranchpriv.html.php +++ b/module/gitlab/view/browsebranchpriv.html.php @@ -62,8 +62,10 @@ push_access_level];?> name)), " ", '', "title={$lang->gitlab->editBranchPriv} class='btn btn-primary'"); - if(common::hasPriv('gitlab', 'deleteBranchPriv')) echo html::a($this->createLink('gitlab', 'deleteBranchPriv', "gitlabID=$gitlabID&projectID=$projectID&branch=" . urlencode(helper::safe64Encode($branch->name))), '', 'hiddenwin', "title='{$lang->gitlab->deleteBranchPriv}' class='btn'"); + /* Fix error when request type is PATH_INFO and the branch name contains '-'.*/ + $branchName = str_replace('-', '*', $branch->name); + if(common::hasPriv('gitlab', 'editBranchPriv')) common::printLink('gitlab', 'editBranchPriv', "gitlabID=$gitlabID&projectID=$projectID&branch=$branchName", " ", '', "title={$lang->gitlab->editBranchPriv} class='btn btn-primary'"); + if(common::hasPriv('gitlab', 'deleteBranchPriv')) echo html::a($this->createLink('gitlab', 'deleteBranchPriv', "gitlabID=$gitlabID&projectID=$projectID&branch=$branchName"), '', 'hiddenwin', "title='{$lang->gitlab->deleteBranchPriv}' class='btn'"); ?> diff --git a/module/gitlab/view/browsetag.html.php b/module/gitlab/view/browsetag.html.php index c9b2378715..70b94923a0 100644 --- a/module/gitlab/view/browsetag.html.php +++ b/module/gitlab/view/browsetag.html.php @@ -67,8 +67,10 @@ updated?> name); $isDisabled = $gitlabTag->protected ? 'disabled' : ''; - common::printLink('gitlab', 'deleteTag', "gitlabID=$gitlabID&projectID={$projectID}&tag_name=" . urlencode(helper::safe64Encode($gitlabTag->name)), " ", '', "title='{$lang->gitlab->deleteTag}' class='btn btn-primary' target='hiddenwin' $isDisabled"); + common::printLink('gitlab', 'deleteTag', "gitlabID=$gitlabID&projectID={$projectID}&tag_name=$tagName", " ", '', "title='{$lang->gitlab->deleteTag}' class='btn btn-primary' target='hiddenwin' $isDisabled"); ?> diff --git a/module/gitlab/view/browsetagpriv.html.php b/module/gitlab/view/browsetagpriv.html.php index 4f1a3f8c36..52d5b8d51b 100644 --- a/module/gitlab/view/browsetagpriv.html.php +++ b/module/gitlab/view/browsetagpriv.html.php @@ -63,8 +63,10 @@ gitlab->branch->branchCreationLevelList, $gitlabTag->accessLevel);?> name)), " ", '', "title={$lang->gitlab->editTagPriv} class='btn btn-primary'"); - common::printLink('gitlab', 'deleteTagPriv', "gitlabID=$gitlabID&projectID={$projectID}&tag_name=" . urlencode(helper::safe64Encode($gitlabTag->name)), " ", '', "title='{$lang->gitlab->deleteTagPriv}' class='btn btn-primary' target='hiddenwin' onclick='if(confirm(\"{$lang->gitlab->tag->protectConfirmDel}\")==false) return false;'"); + /* Fix error when request type is PATH_INFO and the tag name contains '-'.*/ + $tagName = str_replace('-', '*', $gitlabTag->name); + common::printLink('gitlab', 'editTagPriv', "gitlabID=$gitlabID&projectID=$projectID&tag_name=$tagName", " ", '', "title={$lang->gitlab->editTagPriv} class='btn btn-primary'"); + common::printLink('gitlab', 'deleteTagPriv', "gitlabID=$gitlabID&projectID={$projectID}&tag_name=$tagName", " ", '', "title='{$lang->gitlab->deleteTagPriv}' class='btn btn-primary' target='hiddenwin' onclick='if(confirm(\"{$lang->gitlab->tag->protectConfirmDel}\")==false) return false;'"); ?>