1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +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:
epriestley 2015-09-25 10:43:04 -07:00
parent 8ce90a7c42
commit 8d3bb92b91

View file

@ -24,6 +24,8 @@ final class HeraldRuleController extends HeraldController {
} }
$cancel_uri = $this->getApplicationURI("rule/{$id}/"); $cancel_uri = $this->getApplicationURI("rule/{$id}/");
} else { } else {
$new_uri = $this->getApplicationURI('new/');
$rule = new HeraldRule(); $rule = new HeraldRule();
$rule->setAuthorPHID($viewer->getPHID()); $rule->setAuthorPHID($viewer->getPHID());
$rule->setMustMatchAll(1); $rule->setMustMatchAll(1);
@ -33,18 +35,40 @@ final class HeraldRuleController extends HeraldController {
$rule_type = $request->getStr('rule_type'); $rule_type = $request->getStr('rule_type');
if (!isset($rule_type_map[$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); $rule->setRuleType($rule_type);
try {
$adapter = HeraldAdapter::getAdapterForContentType( $adapter = HeraldAdapter::getAdapterForContentType(
$rule->getContentType()); $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())) { if (!$adapter->supportsRuleType($rule->getRuleType())) {
throw new Exception( return $this->newDialog()
->setTitle(pht('Rule/Content Mismatch'))
->appendParagraph(
pht( pht(
"This rule's content type does not support the selected rule ". 'The selected rule type ("%s") is not supported by the selected '.
"type.")); 'content type ("%s").',
$rule->getRuleType(),
$rule->getContentType()))
->addCancelButton($new_uri);
} }
if ($rule->isObjectRule()) { if ($rule->isObjectRule()) {