Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15390950
D21865.id52145.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D21865.id52145.diff
View Options
diff --git a/src/error/PhutilOpaqueEnvelope.php b/src/error/PhutilOpaqueEnvelope.php
--- a/src/error/PhutilOpaqueEnvelope.php
+++ b/src/error/PhutilOpaqueEnvelope.php
@@ -60,6 +60,9 @@
*/
private function mask($string, $noise) {
$result = '';
+ if ($string === null) {
+ return $result;
+ }
for ($ii = 0; $ii < strlen($string); $ii++) {
$s = $string[$ii];
$n = $noise[$ii % strlen($noise)];
diff --git a/src/future/http/status/HTTPFutureHTTPResponseStatus.php b/src/future/http/status/HTTPFutureHTTPResponseStatus.php
--- a/src/future/http/status/HTTPFutureHTTPResponseStatus.php
+++ b/src/future/http/status/HTTPFutureHTTPResponseStatus.php
@@ -13,7 +13,7 @@
// NOTE: Avoiding PhutilUTF8StringTruncator here because this isn't lazy
// and responses may be large.
- if (strlen($body) > 512) {
+ if ($body !== null && strlen($body) > 512) {
$excerpt = substr($body, 0, 512).'...';
} else {
$excerpt = $body;
@@ -21,7 +21,8 @@
$content_type = BaseHTTPFuture::getHeader($headers, 'Content-Type');
$match = null;
- if (preg_match('/;\s*charset=([^;]+)/', $content_type, $match)) {
+ if ($content_type !== null && strlen($content_type)
+ && preg_match('/;\s*charset=([^;]+)/', $content_type, $match)) {
$encoding = trim($match[1], "\"'");
try {
$excerpt = phutil_utf8_convert($excerpt, 'UTF-8', $encoding);
diff --git a/src/future/oauth/PhutilOAuth1Future.php b/src/future/oauth/PhutilOAuth1Future.php
--- a/src/future/oauth/PhutilOAuth1Future.php
+++ b/src/future/oauth/PhutilOAuth1Future.php
@@ -229,7 +229,18 @@
$consumer_secret = $this->consumerSecret->openEnvelope();
}
- $key = urlencode($consumer_secret).'&'.urlencode($this->tokenSecret);
+ $key = '';
+ $consumer_secret = ($consumer_secret !== null ? $consumer_secret : '');
+ if (strlen($consumer_secret)) {
+ $key = urlencode($consumer_secret);
+ }
+ $token_secret = ($this->tokenSecret !== null ? $this->tokenSecret : '');
+ if (strlen($token_secret)) {
+ if (strlen($key)) {
+ $key = $key.'&';
+ }
+ $key = $key.urlencode($token_secret);
+ }
switch ($this->signatureMethod) {
case 'HMAC-SHA1':
diff --git a/src/parser/ArcanistBundle.php b/src/parser/ArcanistBundle.php
--- a/src/parser/ArcanistBundle.php
+++ b/src/parser/ArcanistBundle.php
@@ -762,26 +762,25 @@
$old_data = $this->getBlob($old_phid, $name);
}
- $old_length = strlen($old_data);
-
- // Here, and below, the binary will be emitted with base85 encoding. This
- // encoding encodes each 4 bytes of input in 5 bytes of output, so we may
- // need up to 5/4ths as many bytes to represent it.
-
- // We reserve space up front because base85 encoding isn't super cheap. If
- // the blob is enormous, we'd rather just bail out now before doing a ton
- // of work and then throwing it away anyway.
-
- // However, the data is compressed before it is emitted so we may actually
- // end up using fewer bytes. For now, the allocator just assumes the worst
- // case since it isn't important to be precise, but we could do a more
- // exact job of this.
- $this->reserveBytes($old_length * 5 / 4);
-
if ($old_data === null) {
+ $old_length = 0;
$old_data = '';
$old_sha1 = str_repeat('0', 40);
} else {
+ // Here, and below, the binary will be emitted with base85 encoding. This
+ // encoding encodes each 4 bytes of input in 5 bytes of output, so we may
+ // need up to 5/4ths as many bytes to represent it.
+
+ // We reserve space up front because base85 encoding isn't super cheap. If
+ // the blob is enormous, we'd rather just bail out now before doing a ton
+ // of work and then throwing it away anyway.
+
+ // However, the data is compressed before it is emitted so we may actually
+ // end up using fewer bytes. For now, the allocator just assumes the worst
+ // case since it isn't important to be precise, but we could do a more
+ // exact job of this.
+ $old_length = strlen($old_data);
+ $this->reserveBytes($old_length * 5 / 4);
$old_sha1 = sha1("blob {$old_length}\0{$old_data}");
}
@@ -795,13 +794,13 @@
$new_data = $this->getBlob($new_phid, $name);
}
- $new_length = strlen($new_data);
- $this->reserveBytes($new_length * 5 / 4);
-
if ($new_data === null) {
+ $new_length = 0;
$new_data = '';
$new_sha1 = str_repeat('0', 40);
} else {
+ $new_length = strlen($new_data);
+ $this->reserveBytes($new_length * 5 / 4);
$new_sha1 = sha1("blob {$new_length}\0{$new_data}");
}
diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php
--- a/src/parser/ArcanistDiffParser.php
+++ b/src/parser/ArcanistDiffParser.php
@@ -263,7 +263,9 @@
// searching for "diff -r" or "diff --git" in the text.
$this->saveLine();
$line = $this->nextLineThatLooksLikeDiffStart();
- if (!$this->tryMatchHeader($patterns, $line, $match)) {
+ if ($line === null
+ || !$this->tryMatchHeader($patterns, $line, $match)) {
+
// Restore line before guessing to display correct error.
$this->restoreLine();
$failed_parse = true;
diff --git a/src/parser/xhpast/__tests__/PHPASTParserTestCase.php b/src/parser/xhpast/__tests__/PHPASTParserTestCase.php
--- a/src/parser/xhpast/__tests__/PHPASTParserTestCase.php
+++ b/src/parser/xhpast/__tests__/PHPASTParserTestCase.php
@@ -82,7 +82,7 @@
case 'pass':
$this->assertEqual(0, $err, pht('Exit code for "%s".', $name));
- if (!strlen($expect)) {
+ if ($expect === null || !strlen($expect)) {
// If there's no "expect" data in the test case, that's OK.
break;
}
diff --git a/src/parser/xhpast/api/XHPASTNode.php b/src/parser/xhpast/api/XHPASTNode.php
--- a/src/parser/xhpast/api/XHPASTNode.php
+++ b/src/parser/xhpast/api/XHPASTNode.php
@@ -239,7 +239,7 @@
$esc = false;
switch ($c) {
case 'x':
- $u = isset($value[$ii + 1]) ? $value[$ii + 1] : null;
+ $u = isset($value[$ii + 1]) ? $value[$ii + 1] : '';
if (!preg_match('/^[a-f0-9]/i', $u)) {
// PHP treats \x followed by anything which is not a hex digit
// as a literal \x.
diff --git a/src/utils/utils.php b/src/utils/utils.php
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -1307,7 +1307,7 @@
function phutil_json_decode($string) {
$result = @json_decode($string, true);
- if (!is_array($result)) {
+ if ($string !== null && !is_array($result)) {
// Failed to decode the JSON. Try to use @{class:PhutilJSONParser} instead.
// This will probably fail, but will throw a useful exception.
$parser = new PhutilJSONParser();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 7:29 AM (6 d, 11 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706542
Default Alt Text
D21865.id52145.diff (6 KB)
Attached To
Mode
D21865: Updates for PHP 8.2 compatibility - Arcanist
Attached
Detach File
Event Timeline
Log In to Comment