Skip to content

Commit b19aea7

Browse files
wilkolazkiGrahamCampbell
authored andcommitted
[11.11] Fix double encoding of job name in artifacts download (#773)
* Fix double encoding of $job_name Removed call to self::encodePath, as the `job` parameter is part of a url query, which is later encoded by `QueryStringBuilder` in `AbstractApi::prepareUri` * Use `job name` with space to test url encoding
1 parent 671b76e commit b19aea7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Api/Jobs.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function artifacts($project_id, int $job_id)
150150
public function artifactsByRefName($project_id, string $ref_name, string $job_name)
151151
{
152152
return $this->getAsResponse('projects/'.self::encodePath($project_id).'/jobs/artifacts/'.self::encodePath($ref_name).'/download', [
153-
'job' => self::encodePath($job_name),
153+
'job' => $job_name,
154154
])->getBody();
155155
}
156156

@@ -165,7 +165,7 @@ public function artifactsByRefName($project_id, string $ref_name, string $job_na
165165
public function artifactByRefName($project_id, string $ref_name, string $job_name, string $artifact_path)
166166
{
167167
return $this->getAsResponse('projects/'.self::encodePath($project_id).'/jobs/artifacts/'.self::encodePath($ref_name).'/raw/'.self::encodePath($artifact_path), [
168-
'job' => self::encodePath($job_name),
168+
'job' => $job_name,
169169
])->getBody();
170170
}
171171

tests/Api/JobsTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ public function shouldGetArtifactsByRefName(): void
147147
$api->expects($this->once())
148148
->method('getAsResponse')
149149
->with('projects/1/jobs/artifacts/master/download', [
150-
'job' => 'job_name',
150+
'job' => 'job name',
151151
])
152152
->will($this->returnValue($returnedStream))
153153
;
154154

155-
$this->assertEquals('foobar', $api->artifactsByRefName(1, 'master', 'job_name')->getContents());
155+
$this->assertEquals('foobar', $api->artifactsByRefName(1, 'master', 'job name')->getContents());
156156
}
157157

158158
/**
@@ -165,11 +165,11 @@ public function shouldGetArtifactByRefName(): void
165165
$api->expects($this->once())
166166
->method('getAsResponse')
167167
->with('projects/1/jobs/artifacts/master/raw/artifact_path', [
168-
'job' => 'job_name',
168+
'job' => 'job name',
169169
])
170170
->will($this->returnValue($returnedStream))
171171
;
172-
$this->assertEquals('foobar', $api->artifactByRefName(1, 'master', 'job_name', 'artifact_path')->getContents());
172+
$this->assertEquals('foobar', $api->artifactByRefName(1, 'master', 'job name', 'artifact_path')->getContents());
173173
}
174174

175175
/**

0 commit comments

Comments
 (0)