mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Make some Herald errors more spider-resistant
Summary: Fixes T9328. There's no way to hit these error states by clicking things in the UI that I could find, but if you mash stuff into your URL bar or "Inspect Element..." and then edit the form to be full of garbage you can hit them. Make them a little more informative and don't send them to the log, since these are pretty much just fancy 404s. Test Plan: Bashed my fist on the URL bar to hit all these messages. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9328 Differential Revision: https://secure.phabricator.com/D14164
This commit is contained in:
parent
8ce90a7c42
commit
8d3bb92b91
1 changed files with 31 additions and 7 deletions
|
@ -24,6 +24,8 @@ final class HeraldRuleController extends HeraldController {
|
|||
}
|
||||
$cancel_uri = $this->getApplicationURI("rule/{$id}/");
|
||||
} else {
|
||||
$new_uri = $this->getApplicationURI('new/');
|
||||
|
||||
$rule = new HeraldRule();
|
||||
$rule->setAuthorPHID($viewer->getPHID());
|
||||
$rule->setMustMatchAll(1);
|
||||
|
@ -33,18 +35,40 @@ final class HeraldRuleController extends HeraldController {
|
|||
|
||||
$rule_type = $request->getStr('rule_type');
|
||||
if (!isset($rule_type_map[$rule_type])) {
|
||||
$rule_type = HeraldRuleTypeConfig::RULE_TYPE_PERSONAL;
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Invalid Rule Type'))
|
||||
->appendParagraph(
|
||||
pht(
|
||||
'The selected rule type ("%s") is not recognized by Herald.',
|
||||
$rule_type))
|
||||
->addCancelButton($new_uri);
|
||||
}
|
||||
$rule->setRuleType($rule_type);
|
||||
|
||||
$adapter = HeraldAdapter::getAdapterForContentType(
|
||||
$rule->getContentType());
|
||||
try {
|
||||
$adapter = HeraldAdapter::getAdapterForContentType(
|
||||
$rule->getContentType());
|
||||
} catch (Exception $ex) {
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Invalid Content Type'))
|
||||
->appendParagraph(
|
||||
pht(
|
||||
'The selected content type ("%s") is not recognized by '.
|
||||
'Herald.',
|
||||
$rule->getContentType()))
|
||||
->addCancelButton($new_uri);
|
||||
}
|
||||
|
||||
if (!$adapter->supportsRuleType($rule->getRuleType())) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
"This rule's content type does not support the selected rule ".
|
||||
"type."));
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Rule/Content Mismatch'))
|
||||
->appendParagraph(
|
||||
pht(
|
||||
'The selected rule type ("%s") is not supported by the selected '.
|
||||
'content type ("%s").',
|
||||
$rule->getRuleType(),
|
||||
$rule->getContentType()))
|
||||
->addCancelButton($new_uri);
|
||||
}
|
||||
|
||||
if ($rule->isObjectRule()) {
|
||||
|
|
Loading…
Reference in a new issue