Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15376576
D18830.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D18830.diff
View Options
diff --git a/src/applications/files/conduit/FileUploadChunkConduitAPIMethod.php b/src/applications/files/conduit/FileUploadChunkConduitAPIMethod.php
--- a/src/applications/files/conduit/FileUploadChunkConduitAPIMethod.php
+++ b/src/applications/files/conduit/FileUploadChunkConduitAPIMethod.php
@@ -64,6 +64,7 @@
$params = array(
'name' => $file->getMonogram().'.chunk-'.$chunk->getID(),
'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
+ 'chunk' => true,
);
if ($mime_type !== null) {
diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php
--- a/src/applications/files/storage/PhabricatorFile.php
+++ b/src/applications/files/storage/PhabricatorFile.php
@@ -40,6 +40,7 @@
const METADATA_PROFILE = 'profile';
const METADATA_STORAGE = 'storage';
const METADATA_INTEGRITY = 'integrity';
+ const METADATA_CHUNK = 'chunk';
const STATUS_ACTIVE = 'active';
const STATUS_DELETED = 'deleted';
@@ -410,7 +411,7 @@
try {
$file->updateDimensions(false);
} catch (Exception $ex) {
- // Do nothing
+ // Do nothing.
}
$file->saveAndIndex();
@@ -1057,9 +1058,20 @@
throw new Exception(pht('Cannot retrieve image information.'));
}
+ if ($this->getIsChunk()) {
+ throw new Exception(
+ pht('Refusing to assess image dimensions of file chunk.'));
+ }
+
+ $engine = $this->instantiateStorageEngine();
+ if ($engine->isChunkEngine()) {
+ throw new Exception(
+ pht('Refusing to assess image dimensions of chunked file.'));
+ }
+
$data = $this->loadFileData();
- $img = imagecreatefromstring($data);
+ $img = @imagecreatefromstring($data);
if ($img === false) {
throw new Exception(pht('Error when decoding image.'));
}
@@ -1255,6 +1267,15 @@
return $this;
}
+ public function getIsChunk() {
+ return idx($this->metadata, self::METADATA_CHUNK);
+ }
+
+ public function setIsChunk($value) {
+ $this->metadata[self::METADATA_CHUNK] = $value;
+ return $this;
+ }
+
public function setIntegrityHash($integrity_hash) {
$this->metadata[self::METADATA_INTEGRITY] = $integrity_hash;
return $this;
@@ -1339,6 +1360,7 @@
'mime-type' => 'optional string',
'builtin' => 'optional string',
'storageEngines' => 'optional list<PhabricatorFileStorageEngine>',
+ 'chunk' => 'optional bool',
));
$file_name = idx($params, 'name');
@@ -1416,6 +1438,11 @@
$this->setMimeType($mime_type);
}
+ $is_chunk = idx($params, 'chunk');
+ if ($is_chunk) {
+ $this->setIsChunk(true);
+ }
+
return $this;
}
diff --git a/src/applications/files/uploadsource/PhabricatorFileUploadSource.php b/src/applications/files/uploadsource/PhabricatorFileUploadSource.php
--- a/src/applications/files/uploadsource/PhabricatorFileUploadSource.php
+++ b/src/applications/files/uploadsource/PhabricatorFileUploadSource.php
@@ -189,6 +189,7 @@
$params = array(
'name' => $file->getMonogram().'.chunk-'.$offset,
'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
+ 'chunk' => true,
);
// If this isn't the initial chunk, provide a dummy MIME type so we do not
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 14, 4:34 AM (4 d, 12 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7601596
Default Alt Text
D18830.diff (3 KB)
Attached To
Mode
D18830: Stop trying to assess the image dimensions of large files and file chunks
Attached
Detach File
Event Timeline
Log In to Comment