mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
When a client submits an overlong "sourcePath", truncate it and continue
Summary: Ref T13385. Currently, if you run `arc diff` in a CWD with more than 255 characters, the workflow fatals against the length of the `sourcePath` database column. In the long term, removing this property is likely desirable. For now, truncate long values and continue. This only meaningfully impacts relatively obscure interactive SVN workflows negatively, and even there, "some arc commands are glitchy in very long working directories in SVN" is still better than "arc diff fatals". Test Plan: - Modified `arc` to submit very long source paths. - Ran `arc diff`. - Before: Fatal when inserting >255 characters into `sourcePath`. - After: Path truncated at 255 bytes. Maniphest Tasks: T13385 Differential Revision: https://secure.phabricator.com/D20727
This commit is contained in:
parent
c439931373
commit
5741514aeb
1 changed files with 18 additions and 1 deletions
|
@ -119,8 +119,11 @@ final class DifferentialCreateDiffConduitAPIMethod
|
|||
break;
|
||||
}
|
||||
|
||||
$source_path = $request->getValue('sourcePath');
|
||||
$source_path = $this->normalizeSourcePath($source_path);
|
||||
|
||||
$diff_data_dict = array(
|
||||
'sourcePath' => $request->getValue('sourcePath'),
|
||||
'sourcePath' => $source_path,
|
||||
'sourceMachine' => $request->getValue('sourceMachine'),
|
||||
'branch' => $request->getValue('branch'),
|
||||
'creationMethod' => $request->getValue('creationMethod'),
|
||||
|
@ -158,4 +161,18 @@ final class DifferentialCreateDiffConduitAPIMethod
|
|||
);
|
||||
}
|
||||
|
||||
private function normalizeSourcePath($source_path) {
|
||||
// See T13385. This property is probably headed for deletion. Until we get
|
||||
// there, stop errors arising from running "arc diff" in a working copy
|
||||
// with too many characters.
|
||||
|
||||
$max_size = id(new DifferentialDiff())
|
||||
->getColumnMaximumByteLength('sourcePath');
|
||||
|
||||
return id(new PhutilUTF8StringTruncator())
|
||||
->setMaximumBytes($max_size)
|
||||
->setTerminator('')
|
||||
->truncateString($source_path);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue