Skip to content

Commit 9260bf1

Browse files
committed
Encode artifact filenames when combined as URL
1 parent 3bdd8fc commit 9260bf1

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

application/common/models/Build.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,15 @@ public function getArtifactUrlBase() {
498498
return $this->artifact_url_base;
499499
}
500500

501+
public function encodeFilename($filename) {
502+
return rawurlencode($filename);
503+
}
504+
501505
private function getArtifactUrl($pattern) {
502506
$filename = $this->getArtifactFilename($pattern);
503507
if (!empty($filename))
504508
{
505-
return $this->artifact_url_base . $filename;
509+
return $this->artifact_url_base . $this->encodeFilename($filename);
506510
}
507511
return null;
508512
}
@@ -536,7 +540,7 @@ private function getArtifactUrls($pattern) {
536540
{
537541
$urls = array();
538542
foreach ($filenames as $filename) {
539-
array_push($urls, $this->artifact_url_base . $filename);
543+
array_push($urls, $this->artifact_url_base . $this->encodeFilename($filename));
540544
}
541545
return $urls;
542546
}

application/tests/unit/common/components/BuildTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,10 @@ public function testFindAllRunningByJobId()
9191
$this->assertEquals(2, $numberOfRunningBuilds, " *** Incorrect number of active builds");
9292

9393
}
94+
public function testArtifactEncoding() {
95+
$this->setContainerObjects();
96+
$build = Build::findOne(['id' => 12]);
97+
$apks = $build->apks();
98+
$this->assertContains("https://s3-us-west-2.amazonaws.com/sil-appbuilder-artifacts/testing/jobs/build_scriptureappbuilder_22/1/Test%2B1.0.apk", $apks, " *** filename not encoded correctly");
99+
}
94100
}

application/tests/unit/fixtures/data/common/models/Build.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
'result' => 'SUCCESS',
2626
'error' => NULL,
2727
'artifact_url_base' => 'https://s3-us-west-2.amazonaws.com/sil-appbuilder-artifacts/testing/jobs/build_scriptureappbuilder_22/1/',
28-
'artifact_files' => 'about.txt,console.log,package_name.txt,Test-1.0-output.log,Test-1.0.apk,version.json,version_code.txt,whats_new.txt,play-listing/index.html,play-listing/manifest.json',
28+
'artifact_files' => 'about.txt,console.log,package_name.txt,Test+1.0-output.log,Test+1.0.apk,version.json,version_code.txt,whats_new.txt,play-listing/index.html,play-listing/manifest.json',
2929
'created' => Utils::getDatetime(),
3030
'updated' => Utils::getDatetime(),
3131
'channel' => 'unpublished',

0 commit comments

Comments
 (0)