From 4dadad53ae5dc2e6ba50e8ff96cf3269b1041333 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 22 Nov 2016 14:15:45 -0800 Subject: [PATCH] Prevent media from autoplaying when rendered as a feed story Summary: Fixes T11845. Users can still embed a text panel on the home page to give it some ambiance. Test Plan: Wrote an autoplay video as a comment, saw it in feed. Before change: autoplay. After change: no auto play. On task: still autoplay. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11845 Differential Revision: https://secure.phabricator.com/D16920 --- src/applications/feed/story/PhabricatorFeedStory.php | 2 +- .../files/markup/PhabricatorEmbedFileRemarkupRule.php | 6 ++++++ src/infrastructure/markup/PhabricatorMarkupEngine.php | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/applications/feed/story/PhabricatorFeedStory.php b/src/applications/feed/story/PhabricatorFeedStory.php index 8a15301216..c3984573c7 100644 --- a/src/applications/feed/story/PhabricatorFeedStory.php +++ b/src/applications/feed/story/PhabricatorFeedStory.php @@ -462,7 +462,7 @@ abstract class PhabricatorFeedStory } public function newMarkupEngine($field) { - return PhabricatorMarkupEngine::getEngine(); + return PhabricatorMarkupEngine::getEngine('feed'); } public function getMarkupText($field) { diff --git a/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php b/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php index 0fb2243d89..e054c2acd9 100644 --- a/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php +++ b/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php @@ -252,6 +252,12 @@ final class PhabricatorEmbedFileRemarkupRule $autoplay = null; } + // Rendering contexts like feed can disable autoplay. + $engine = $this->getEngine(); + if ($engine->getConfig('autoplay.disable')) { + $autoplay = null; + } + return $this->newTag( $tag, array( diff --git a/src/infrastructure/markup/PhabricatorMarkupEngine.php b/src/infrastructure/markup/PhabricatorMarkupEngine.php index 6f13525c76..3ce5578f82 100644 --- a/src/infrastructure/markup/PhabricatorMarkupEngine.php +++ b/src/infrastructure/markup/PhabricatorMarkupEngine.php @@ -414,6 +414,10 @@ final class PhabricatorMarkupEngine extends Phobject { case 'default': $engine = self::newMarkupEngine(array()); break; + case 'feed': + $engine = self::newMarkupEngine(array()); + $engine->setConfig('autoplay.disable', true); + break; case 'nolinebreaks': $engine = self::newMarkupEngine(array()); $engine->setConfig('preserve-linebreaks', false);