Skip to content

Commit 62acfd1

Browse files
authored
[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 7cd35ef commit 62acfd1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Api/Jobs.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function artifacts($project_id, int $job_id)
151151
public function artifactsByRefName($project_id, string $ref_name, string $job_name)
152152
{
153153
return $this->getAsResponse('projects/'.self::encodePath($project_id).'/jobs/artifacts/'.self::encodePath($ref_name).'/download', [
154-
'job' => self::encodePath($job_name),
154+
'job' => $job_name,
155155
])->getBody();
156156
}
157157

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

tests/Api/JobsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ public function shouldGetArtifactsByRefName(): void
171171
$api->expects($this->once())
172172
->method('getAsResponse')
173173
->with('projects/1/jobs/artifacts/master/download', [
174-
'job' => 'job_name',
174+
'job' => 'job name',
175175
])
176176
->will($this->returnValue($returnedStream))
177177
;
178178

179-
$this->assertEquals('foobar', $api->artifactsByRefName(1, 'master', 'job_name')->getContents());
179+
$this->assertEquals('foobar', $api->artifactsByRefName(1, 'master', 'job name')->getContents());
180180
}
181181

182182
/**
@@ -189,11 +189,11 @@ public function shouldGetArtifactByRefName(): void
189189
$api->expects($this->once())
190190
->method('getAsResponse')
191191
->with('projects/1/jobs/artifacts/master/raw/artifact_path', [
192-
'job' => 'job_name',
192+
'job' => 'job name',
193193
])
194194
->will($this->returnValue($returnedStream))
195195
;
196-
$this->assertEquals('foobar', $api->artifactByRefName(1, 'master', 'job_name', 'artifact_path')->getContents());
196+
$this->assertEquals('foobar', $api->artifactByRefName(1, 'master', 'job name', 'artifact_path')->getContents());
197197
}
198198

199199
/**

0 commit comments

Comments
 (0)