Page MenuHomePhabricator

D21761.diff
No OneTemporary

D21761.diff

diff --git a/src/applications/diffusion/herald/HeraldCommitAdapter.php b/src/applications/diffusion/herald/HeraldCommitAdapter.php
--- a/src/applications/diffusion/herald/HeraldCommitAdapter.php
+++ b/src/applications/diffusion/herald/HeraldCommitAdapter.php
@@ -267,6 +267,11 @@
$raw = $diff_file->loadFileData();
+ // See T13667. This happens when a commit is empty and affects no files.
+ if (!strlen($raw)) {
+ return false;
+ }
+
$parser = new ArcanistDiffParser();
$changes = $parser->parseDiff($raw);
@@ -290,6 +295,10 @@
}
}
+ if ($this->commitDiff === false) {
+ return array();
+ }
+
if ($this->commitDiff instanceof Exception) {
$ex = $this->commitDiff;
$ex_class = get_class($ex);
diff --git a/src/applications/diffusion/query/pathchange/DiffusionPathChangeQuery.php b/src/applications/diffusion/query/pathchange/DiffusionPathChangeQuery.php
--- a/src/applications/diffusion/query/pathchange/DiffusionPathChangeQuery.php
+++ b/src/applications/diffusion/query/pathchange/DiffusionPathChangeQuery.php
@@ -88,7 +88,12 @@
$change->setFileType($raw_change['fileType']);
$change->setCommitIdentifier($commit->getCommitIdentifier());
- $change->setTargetPath(ltrim($raw_change['targetPathName'], '/'));
+ $target_path = $raw_change['targetPathName'];
+ if ($target_path !== null) {
+ $target_path = ltrim($target_path, '/');
+ }
+ $change->setTargetPath($target_path);
+
$change->setTargetCommitIdentifier($raw_change['targetCommitIdentifier']);
$id = $raw_change['pathID'];
diff --git a/src/applications/diffusion/request/DiffusionRequest.php b/src/applications/diffusion/request/DiffusionRequest.php
--- a/src/applications/diffusion/request/DiffusionRequest.php
+++ b/src/applications/diffusion/request/DiffusionRequest.php
@@ -207,7 +207,7 @@
*/
private function initializeFromDictionary(array $data) {
$blob = idx($data, 'blob');
- if (strlen($blob)) {
+ if (phutil_nonempty_string($blob)) {
$blob = self::parseRequestBlob($blob, $this->supportsBranches());
$data = $blob + $data;
}
@@ -518,12 +518,14 @@
$result['path'] = $blob;
}
- $parts = explode('/', $result['path']);
- foreach ($parts as $part) {
- // Prevent any hyjinx since we're ultimately shipping this to the
- // filesystem under a lot of workflows.
- if ($part == '..') {
- throw new Exception(pht('Invalid path URI.'));
+ if ($result['path'] !== null) {
+ $parts = explode('/', $result['path']);
+ foreach ($parts as $part) {
+ // Prevent any hyjinx since we're ultimately shipping this to the
+ // filesystem under a lot of workflows.
+ if ($part == '..') {
+ throw new Exception(pht('Invalid path URI.'));
+ }
}
}
diff --git a/src/applications/macro/query/PhabricatorMacroQuery.php b/src/applications/macro/query/PhabricatorMacroQuery.php
--- a/src/applications/macro/query/PhabricatorMacroQuery.php
+++ b/src/applications/macro/query/PhabricatorMacroQuery.php
@@ -128,7 +128,7 @@
$this->authorPHIDs);
}
- if (strlen($this->nameLike)) {
+ if (($this->nameLike !== null) && strlen($this->nameLike)) {
$where[] = qsprintf(
$conn,
'm.name LIKE %~',
@@ -142,7 +142,7 @@
$this->names);
}
- if (strlen($this->namePrefix)) {
+ if (($this->namePrefix !== null) && strlen($this->namePrefix)) {
$where[] = qsprintf(
$conn,
'm.name LIKE %>',
diff --git a/src/applications/passphrase/query/PassphraseCredentialQuery.php b/src/applications/passphrase/query/PassphraseCredentialQuery.php
--- a/src/applications/passphrase/query/PassphraseCredentialQuery.php
+++ b/src/applications/passphrase/query/PassphraseCredentialQuery.php
@@ -148,7 +148,7 @@
(int)$this->allowConduit);
}
- if (strlen($this->nameContains)) {
+ if (phutil_nonempty_string($this->nameContains)) {
$where[] = qsprintf(
$conn,
'LOWER(c.name) LIKE %~',
diff --git a/src/applications/repository/query/PhabricatorRepositoryQuery.php b/src/applications/repository/query/PhabricatorRepositoryQuery.php
--- a/src/applications/repository/query/PhabricatorRepositoryQuery.php
+++ b/src/applications/repository/query/PhabricatorRepositoryQuery.php
@@ -633,7 +633,7 @@
$this->uuids);
}
- if (strlen($this->datasourceQuery)) {
+ if (phutil_nonempty_string($this->datasourceQuery)) {
// This handles having "rP" match callsigns starting with "P...".
$query = trim($this->datasourceQuery);
if (preg_match('/^r/', $query)) {
diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php
--- a/src/applications/repository/storage/PhabricatorRepository.php
+++ b/src/applications/repository/storage/PhabricatorRepository.php
@@ -281,9 +281,11 @@
public function getSubversionBaseURI($commit = null) {
$subpath = $this->getDetail('svn-subpath');
- if (!strlen($subpath)) {
+
+ if (!phutil_nonempty_string($subpath)) {
$subpath = null;
}
+
return $this->getSubversionPathURI($subpath, $commit);
}
@@ -301,7 +303,7 @@
$uri = rtrim($uri, '/');
- if (strlen($path)) {
+ if (phutil_nonempty_string($path)) {
$path = rawurlencode($path);
$path = str_replace('%2F', '/', $path);
$uri = $uri.'/'.ltrim($path, '/');
@@ -574,12 +576,12 @@
public function getURI() {
$short_name = $this->getRepositorySlug();
- if (strlen($short_name)) {
+ if (phutil_nonempty_string($short_name)) {
return "/source/{$short_name}/";
}
$callsign = $this->getCallsign();
- if (strlen($callsign)) {
+ if (phutil_nonempty_string($callsign)) {
return "/diffusion/{$callsign}/";
}
@@ -593,7 +595,7 @@
public function getCommitURI($identifier) {
$callsign = $this->getCallsign();
- if (strlen($callsign)) {
+ if (phutil_nonempty_string($callsign)) {
return "/r{$callsign}{$identifier}";
}
@@ -736,25 +738,25 @@
return $this->getCommitURI($commit);
}
- if (strlen($path)) {
+ if (phutil_nonempty_string($path)) {
$path = ltrim($path, '/');
$path = str_replace(array(';', '$'), array(';;', '$$'), $path);
$path = phutil_escape_uri($path);
}
$raw_branch = $branch;
- if (strlen($branch)) {
+ if (phutil_nonempty_string($branch)) {
$branch = phutil_escape_uri_path_component($branch);
$path = "{$branch}/{$path}";
}
$raw_commit = $commit;
- if (strlen($commit)) {
+ if (phutil_nonempty_string($commit)) {
$commit = str_replace('$', '$$', $commit);
$commit = ';'.phutil_escape_uri($commit);
}
- if (strlen($line)) {
+ if (phutil_nonempty_string($line)) {
$line = '$'.phutil_escape_uri($line);
}
@@ -862,7 +864,7 @@
public function getDefaultBranch() {
$default = $this->getDetail('default-branch');
- if (strlen($default)) {
+ if (phutil_nonempty_string($default)) {
return $default;
}
diff --git a/src/infrastructure/markup/PhabricatorMarkupEngine.php b/src/infrastructure/markup/PhabricatorMarkupEngine.php
--- a/src/infrastructure/markup/PhabricatorMarkupEngine.php
+++ b/src/infrastructure/markup/PhabricatorMarkupEngine.php
@@ -583,6 +583,14 @@
$engine->setConfig('viewer', $viewer);
foreach ($content_blocks as $content_block) {
+ if ($content_block === null) {
+ continue;
+ }
+
+ if (!strlen($content_block)) {
+ continue;
+ }
+
$engine->markupText($content_block);
$phids = $engine->getTextMetadata(
PhabricatorMentionRemarkupRule::KEY_MENTIONED,
diff --git a/src/infrastructure/markup/render.php b/src/infrastructure/markup/render.php
--- a/src/infrastructure/markup/render.php
+++ b/src/infrastructure/markup/render.php
@@ -105,6 +105,10 @@
}
function phutil_escape_html($string) {
+ if ($string === null) {
+ return '';
+ }
+
if ($string instanceof PhutilSafeHTML) {
return $string;
} else if ($string instanceof PhutilSafeHTMLProducerInterface) {

File Metadata

Mime Type
text/plain
Expires
Thu, May 9, 8:05 PM (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6276362
Default Alt Text
D21761.diff (8 KB)

Event Timeline