Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14347446
D16887.id40653.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D16887.id40653.diff
View Options
diff --git a/src/applications/harbormaster/artifact/HarbormasterArtifact.php b/src/applications/harbormaster/artifact/HarbormasterArtifact.php
--- a/src/applications/harbormaster/artifact/HarbormasterArtifact.php
+++ b/src/applications/harbormaster/artifact/HarbormasterArtifact.php
@@ -16,6 +16,10 @@
abstract public function getArtifactParameterDescriptions();
abstract public function willCreateArtifact(PhabricatorUser $actor);
+ public function readArtifactHTTPParameter($key, $value) {
+ return $value;
+ }
+
public function validateArtifactData(array $artifact_data) {
$artifact_spec = $this->getArtifactParameterSpecification();
PhutilTypeSpec::checkMap($artifact_data, $artifact_spec);
diff --git a/src/applications/harbormaster/artifact/HarbormasterURIArtifact.php b/src/applications/harbormaster/artifact/HarbormasterURIArtifact.php
--- a/src/applications/harbormaster/artifact/HarbormasterURIArtifact.php
+++ b/src/applications/harbormaster/artifact/HarbormasterURIArtifact.php
@@ -27,6 +27,16 @@
);
}
+ public function readArtifactHTTPParameter($key, $value) {
+ // TODO: This is hacky and artifact parameters should be replaced more
+ // broadly, likely with EditFields. See T11887.
+ switch ($key) {
+ case 'ui.external':
+ return (bool)$value;
+ }
+ return $value;
+ }
+
public function getArtifactParameterDescriptions() {
return array(
'uri' => pht('The URI to store.'),
diff --git a/src/applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php b/src/applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php
--- a/src/applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php
+++ b/src/applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php
@@ -115,11 +115,28 @@
$build_target_phid));
}
+ $artifact_type = $request->getValue('artifactType');
+
+ // Cast "artifactData" parameters to acceptable types if this request
+ // is submitting raw HTTP parameters. This is not ideal. See T11887 for
+ // discussion.
+ $artifact_data = $request->getValue('artifactData');
+ if (!$request->getIsStrictlyTyped()) {
+ $impl = HarbormasterArtifact::getArtifactType($artifact_type);
+ if ($impl) {
+ foreach ($artifact_data as $key => $value) {
+ $artifact_data[$key] = $impl->readArtifactHTTPParameter(
+ $key,
+ $value);
+ }
+ }
+ }
+
$artifact = $build_target->createArtifact(
$viewer,
$request->getValue('artifactKey'),
- $request->getValue('artifactType'),
- $request->getValue('artifactData'));
+ $artifact_type,
+ $artifact_data);
return array(
'data' => $this->returnArtifactList(array($artifact)),
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 3:02 AM (19 h, 16 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6909302
Default Alt Text
D16887.id40653.diff (2 KB)
Attached To
Mode
D16887: Allow "harbormaster.createartifact" to decode raw HTTP parameter types of artifact properties
Attached
Detach File
Event Timeline
Log In to Comment