From 02f7ece868d890eb3d435da0c27847018277cdb9 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 15 Feb 2013 16:38:46 -0800 Subject: [PATCH] Fix overescaping in Paste Summary: Two issues: - When we read the content out of cache, it has lost its "safe html" flag, since the cache is raw-string oriented. Restore it. - explode() isn't safe-html-safe. Use phutil_split_lines() instead, which is. Test Plan: Looked at /paste/ Reviewers: codeblock, chad Reviewed By: codeblock CC: aran Differential Revision: https://secure.phabricator.com/D4980 --- .../paste/controller/PhabricatorPasteController.php | 2 +- src/applications/paste/query/PhabricatorPasteQuery.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/applications/paste/controller/PhabricatorPasteController.php b/src/applications/paste/controller/PhabricatorPasteController.php index c9b93906a1..9e013da314 100644 --- a/src/applications/paste/controller/PhabricatorPasteController.php +++ b/src/applications/paste/controller/PhabricatorPasteController.php @@ -44,7 +44,7 @@ abstract class PhabricatorPasteController extends PhabricatorController { PhabricatorPaste $paste, $max_lines = null) { - $lines = explode("\n", rtrim($paste->getContent())); + $lines = phutil_split_lines($paste->getContent()); return id(new PhabricatorSourceCodeView()) ->setLimit($max_lines) diff --git a/src/applications/paste/query/PhabricatorPasteQuery.php b/src/applications/paste/query/PhabricatorPasteQuery.php index ccd242cc1c..fe877a7da6 100644 --- a/src/applications/paste/query/PhabricatorPasteQuery.php +++ b/src/applications/paste/query/PhabricatorPasteQuery.php @@ -141,7 +141,7 @@ final class PhabricatorPasteQuery foreach ($pastes as $paste) { $key = $this->getContentCacheKey($paste); if (isset($caches[$key])) { - $paste->attachContent($caches[$key]); + $paste->attachContent(phutil_safe_html($caches[$key])); } else { $need_raw[] = $paste; }