From 1ac84c1b59de12a62ab2b625d3f74aa81cb70fe3 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Thu, 30 Oct 2014 15:24:10 -0700 Subject: [PATCH] Add addLinkSection to MailBody to properly format URIs Summary: Fixes T6343. Grepped for all callsites and added addLinkSection where needed. Test Plan: Tested Differential, Maniphest, Conpherence, Ponder and Macro. Inspect HTML mail for anchor tags. Inspect text mails for non-disruption. Reviewers: epriestley, btrahan Reviewed By: btrahan Subscribers: talshiri, Korvin, epriestley Maniphest Tasks: T6343 Differential Revision: https://secure.phabricator.com/D10762 --- src/applications/audit/editor/PhabricatorAuditEditor.php | 2 +- src/applications/conpherence/editor/ConpherenceEditor.php | 2 +- .../DifferentialChangesSinceLastUpdateField.php | 2 +- .../differential/editor/DifferentialTransactionEditor.php | 4 ++-- src/applications/fund/editor/FundInitiativeEditor.php | 2 +- .../legalpad/editor/LegalpadDocumentEditor.php | 2 +- src/applications/macro/editor/PhabricatorMacroEditor.php | 2 +- .../maniphest/editor/ManiphestTransactionEditor.php | 2 +- .../metamta/view/PhabricatorMetaMTAMailBody.php | 8 +++++++- .../metamta/view/PhabricatorMetaMTAMailSection.php | 1 - src/applications/paste/editor/PhabricatorPasteEditor.php | 2 +- src/applications/pholio/editor/PholioMockEditor.php | 2 +- src/applications/phortune/editor/PhortuneCartEditor.php | 2 +- .../phriction/editor/PhrictionTransactionEditor.php | 2 +- src/applications/ponder/editor/PonderAnswerEditor.php | 2 +- src/applications/ponder/editor/PonderQuestionEditor.php | 2 +- .../worker/PhabricatorRepositoryPushMailWorker.php | 2 +- 17 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/applications/audit/editor/PhabricatorAuditEditor.php b/src/applications/audit/editor/PhabricatorAuditEditor.php index 5d3bc3d881..74e460afdf 100644 --- a/src/applications/audit/editor/PhabricatorAuditEditor.php +++ b/src/applications/audit/editor/PhabricatorAuditEditor.php @@ -678,7 +678,7 @@ final class PhabricatorAuditEditor $monogram = $object->getRepository()->formatCommitName( $object->getCommitIdentifier()); - $body->addTextSection( + $body->addLinkSection( pht('COMMIT'), PhabricatorEnv::getProductionURI('/'.$monogram)); diff --git a/src/applications/conpherence/editor/ConpherenceEditor.php b/src/applications/conpherence/editor/ConpherenceEditor.php index 16ef622c79..d680472c9e 100644 --- a/src/applications/conpherence/editor/ConpherenceEditor.php +++ b/src/applications/conpherence/editor/ConpherenceEditor.php @@ -405,7 +405,7 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { array $xactions) { $body = parent::buildMailBody($object, $xactions); - $body->addTextSection( + $body->addLinkSection( pht('CONPHERENCE DETAIL'), PhabricatorEnv::getProductionURI('/conpherence/'.$object->getID().'/')); diff --git a/src/applications/differential/customfield/DifferentialChangesSinceLastUpdateField.php b/src/applications/differential/customfield/DifferentialChangesSinceLastUpdateField.php index e2eef1788a..a7e3654d0d 100644 --- a/src/applications/differential/customfield/DifferentialChangesSinceLastUpdateField.php +++ b/src/applications/differential/customfield/DifferentialChangesSinceLastUpdateField.php @@ -54,7 +54,7 @@ final class DifferentialChangesSinceLastUpdateField $uri = '/'.$revision->getMonogram().'?vs='.$old_id.'&id='.$new_id; $uri = PhabricatorEnv::getProductionURI($uri); - $body->addTextSection(pht('CHANGES SINCE LAST UPDATE'), $uri); + $body->addLinkSection(pht('CHANGES SINCE LAST UPDATE'), $uri); } } diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php index 85f68768df..dc0058b0f3 100644 --- a/src/applications/differential/editor/DifferentialTransactionEditor.php +++ b/src/applications/differential/editor/DifferentialTransactionEditor.php @@ -1140,7 +1140,7 @@ final class DifferentialTransactionEditor $changed_uri = $this->getChangedPriorToCommitURI(); if ($changed_uri) { - $body->addTextSection( + $body->addLinkSection( pht('CHANGED PRIOR TO COMMIT'), $changed_uri); } @@ -1151,7 +1151,7 @@ final class DifferentialTransactionEditor $this->renderInlineCommentsForMail($object, $inlines)); } - $body->addTextSection( + $body->addLinkSection( pht('REVISION DETAIL'), PhabricatorEnv::getProductionURI('/D'.$object->getID())); diff --git a/src/applications/fund/editor/FundInitiativeEditor.php b/src/applications/fund/editor/FundInitiativeEditor.php index 72bede9069..05041ba119 100644 --- a/src/applications/fund/editor/FundInitiativeEditor.php +++ b/src/applications/fund/editor/FundInitiativeEditor.php @@ -267,7 +267,7 @@ final class FundInitiativeEditor $body = parent::buildMailBody($object, $xactions); - $body->addTextSection( + $body->addLinkSection( pht('INITIATIVE DETAIL'), PhabricatorEnv::getProductionURI('/'.$object->getMonogram())); diff --git a/src/applications/legalpad/editor/LegalpadDocumentEditor.php b/src/applications/legalpad/editor/LegalpadDocumentEditor.php index 80dd262716..98104690d0 100644 --- a/src/applications/legalpad/editor/LegalpadDocumentEditor.php +++ b/src/applications/legalpad/editor/LegalpadDocumentEditor.php @@ -194,7 +194,7 @@ final class LegalpadDocumentEditor $body = parent::buildMailBody($object, $xactions); - $body->addTextSection( + $body->addLinkSection( pht('DOCUMENT DETAIL'), PhabricatorEnv::getProductionURI('/legalpad/view/'.$object->getID().'/')); diff --git a/src/applications/macro/editor/PhabricatorMacroEditor.php b/src/applications/macro/editor/PhabricatorMacroEditor.php index 09d4c99fb4..fe5259a1d2 100644 --- a/src/applications/macro/editor/PhabricatorMacroEditor.php +++ b/src/applications/macro/editor/PhabricatorMacroEditor.php @@ -173,7 +173,7 @@ final class PhabricatorMacroEditor array $xactions) { $body = parent::buildMailBody($object, $xactions); - $body->addTextSection( + $body->addLinkSection( pht('MACRO DETAIL'), PhabricatorEnv::getProductionURI('/macro/view/'.$object->getID().'/')); diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index c2cd4455c8..1fb7d2ec52 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -497,7 +497,7 @@ final class ManiphestTransactionEditor $object->getDescription()); } - $body->addTextSection( + $body->addLinkSection( pht('TASK DETAIL'), PhabricatorEnv::getProductionURI('/T'.$object->getID())); diff --git a/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php b/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php index e52b5c52c0..389549da7b 100644 --- a/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php +++ b/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php @@ -82,7 +82,13 @@ final class PhabricatorMetaMTAMailBody { phutil_tag('div', array('style' => 'font-weight:800;'), $header), $html_fragment, ); + return $this; + } + public function addLinkSection($header, $link) { + $html = phutil_tag('a', array('href' => $link), $link); + $this->addPlaintextSection($header, $link); + $this->addHTMLSection($header, $html); return $this; } @@ -98,7 +104,7 @@ final class PhabricatorMetaMTAMailBody { return $this; } - $this->addTextSection( + $this->addLinkSection( pht('WHY DID I GET THIS EMAIL?'), PhabricatorEnv::getProductionURI($xscript_uri)); diff --git a/src/applications/metamta/view/PhabricatorMetaMTAMailSection.php b/src/applications/metamta/view/PhabricatorMetaMTAMailSection.php index 811b4c3127..701511dda2 100644 --- a/src/applications/metamta/view/PhabricatorMetaMTAMailSection.php +++ b/src/applications/metamta/view/PhabricatorMetaMTAMailSection.php @@ -22,7 +22,6 @@ final class PhabricatorMetaMTAMailSection { public function addHTMLFragment($fragment) { $this->htmlFragments[] = $fragment; return $this; - } public function addPlaintextFragment($fragment) { diff --git a/src/applications/paste/editor/PhabricatorPasteEditor.php b/src/applications/paste/editor/PhabricatorPasteEditor.php index 26c79147f1..6e038fe11d 100644 --- a/src/applications/paste/editor/PhabricatorPasteEditor.php +++ b/src/applications/paste/editor/PhabricatorPasteEditor.php @@ -167,7 +167,7 @@ final class PhabricatorPasteEditor $body = parent::buildMailBody($object, $xactions); - $body->addTextSection( + $body->addLinkSection( pht('PASTE DETAIL'), PhabricatorEnv::getProductionURI('/P'.$object->getID())); diff --git a/src/applications/pholio/editor/PholioMockEditor.php b/src/applications/pholio/editor/PholioMockEditor.php index 9c49e39d52..7ba95455b5 100644 --- a/src/applications/pholio/editor/PholioMockEditor.php +++ b/src/applications/pholio/editor/PholioMockEditor.php @@ -409,7 +409,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor { } } - $body->addTextSection( + $body->addLinkSection( pht('MOCK DETAIL'), PhabricatorEnv::getProductionURI('/M'.$object->getID())); diff --git a/src/applications/phortune/editor/PhortuneCartEditor.php b/src/applications/phortune/editor/PhortuneCartEditor.php index 716d00727c..fb39102624 100644 --- a/src/applications/phortune/editor/PhortuneCartEditor.php +++ b/src/applications/phortune/editor/PhortuneCartEditor.php @@ -123,7 +123,7 @@ final class PhortuneCartEditor $body->addTextSection(pht('ORDER CONTENTS'), implode("\n", $items)); - $body->addTextSection( + $body->addLinkSection( pht('ORDER DETAIL'), PhabricatorEnv::getProductionURI('/phortune/cart/'.$object->getID().'/')); diff --git a/src/applications/phriction/editor/PhrictionTransactionEditor.php b/src/applications/phriction/editor/PhrictionTransactionEditor.php index c857ff979d..546abc3979 100644 --- a/src/applications/phriction/editor/PhrictionTransactionEditor.php +++ b/src/applications/phriction/editor/PhrictionTransactionEditor.php @@ -242,7 +242,7 @@ final class PhrictionTransactionEditor $object->getContent()->getContent()); } - $body->addTextSection( + $body->addLinkSection( pht('DOCUMENT DETAIL'), PhabricatorEnv::getProductionURI( PhrictionDocument::getSlugURI($object->getSlug()))); diff --git a/src/applications/ponder/editor/PonderAnswerEditor.php b/src/applications/ponder/editor/PonderAnswerEditor.php index 9c2792efbf..69ee10f270 100644 --- a/src/applications/ponder/editor/PonderAnswerEditor.php +++ b/src/applications/ponder/editor/PonderAnswerEditor.php @@ -98,7 +98,7 @@ final class PonderAnswerEditor extends PonderEditor { } } - $body->addTextSection( + $body->addLinkSection( pht('ANSWER DETAIL'), PhabricatorEnv::getProductionURI($object->getURI())); diff --git a/src/applications/ponder/editor/PonderQuestionEditor.php b/src/applications/ponder/editor/PonderQuestionEditor.php index f7030dedce..5505e751de 100644 --- a/src/applications/ponder/editor/PonderQuestionEditor.php +++ b/src/applications/ponder/editor/PonderQuestionEditor.php @@ -243,7 +243,7 @@ final class PonderQuestionEditor } } - $body->addTextSection( + $body->addLinkSection( $header, PhabricatorEnv::getProductionURI($uri)); diff --git a/src/applications/repository/worker/PhabricatorRepositoryPushMailWorker.php b/src/applications/repository/worker/PhabricatorRepositoryPushMailWorker.php index 883e547e58..23582d63eb 100644 --- a/src/applications/repository/worker/PhabricatorRepositoryPushMailWorker.php +++ b/src/applications/repository/worker/PhabricatorRepositoryPushMailWorker.php @@ -70,7 +70,7 @@ final class PhabricatorRepositoryPushMailWorker $body = new PhabricatorMetaMTAMailBody(); $body->addRawSection($overview); - $body->addTextSection(pht('DETAILS'), $details_uri); + $body->addLinkSection(pht('DETAILS'), $details_uri); if ($commit_lines) { $body->addTextSection(pht('COMMITS'), implode("\n", $commit_lines));