Skip to content

Commit

Permalink
Add explicit limits to unit test/lint error names
Browse files Browse the repository at this point in the history
Summary:
Fixes T12981.

See new `arc lint` output: P2071

See new `arc unit` output: P2072

Test Plan: Ran `arc unit/lint/diff` and observed new error instead of a Conduit error

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12981

Differential Revision: https://secure.phabricator.com/D18603
  • Loading branch information
phacility-bot committed Sep 14, 2017
1 parent cbc785d commit df81d79
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lint/ArcanistLintMessage.php
Expand Up @@ -126,6 +126,21 @@ public function getSeverity() {
}

public function setName($name) {
$maximum_bytes = 255;
$actual_bytes = strlen($name);

if ($actual_bytes > $maximum_bytes) {
throw new Exception(
pht(
'Parameter ("%s") passed to "%s" when constructing a lint message '.
'must be a string with a maximum length of %s bytes, but is %s '.
'bytes in length.',
$name,
'setName()',
new PhutilNumber($maximum_bytes),
new PhutilNumber($actual_bytes)));
}

$this->name = $name;
return $this;
}
Expand Down
14 changes: 14 additions & 0 deletions src/unit/ArcanistUnitTestResult.php
Expand Up @@ -30,6 +30,20 @@ public function getNamespace() {
}

public function setName($name) {
$maximum_bytes = 255;
$actual_bytes = strlen($name);

if ($actual_bytes > $maximum_bytes) {
throw new Exception(
pht(
'Parameter ("%s") passed to "%s" when constructing a unit test '.
'message must be a string with a maximum length of %s bytes, but '.
'is %s bytes in length.',
$name,
'setName()',
new PhutilNumber($maximum_bytes),
new PhutilNumber($actual_bytes)));
}
$this->name = $name;
return $this;
}
Expand Down

0 comments on commit df81d79

Please sign in to comment.