From df3162584eb759d8dfffa6e85168cfdc18263299 Mon Sep 17 00:00:00 2001 From: David Reuss Date: Sun, 12 Aug 2012 08:50:27 -0700 Subject: [PATCH] Convert to custom encoding for diffusion blame views Summary: If a repository is configured with a custom encoding, it wasn't respected by DiffusionGitFileContentQuery making all views with non-UTF8 characters fail. Check if we have a custom encoding and encode if any it set. NOTE: This only works for Git repositories. Test Plan: Browsed a repository with custom encoding before and after this patch. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T452 Differential Revision: https://secure.phabricator.com/D3251 --- .../query/filecontent/DiffusionFileContentQuery.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/applications/diffusion/query/filecontent/DiffusionFileContentQuery.php b/src/applications/diffusion/query/filecontent/DiffusionFileContentQuery.php index ae1bb2c99f..4ac6169f4e 100644 --- a/src/applications/diffusion/query/filecontent/DiffusionFileContentQuery.php +++ b/src/applications/diffusion/query/filecontent/DiffusionFileContentQuery.php @@ -27,7 +27,17 @@ abstract class DiffusionFileContentQuery extends DiffusionQuery { } final public function loadFileContent() { - return $this->fileContent = $this->executeQuery(); + $this->fileContent = $this->executeQuery(); + + $repository = $this->getRequest()->getRepository(); + $try_encoding = $repository->getDetail('encoding'); + if ($try_encoding) { + $this->fileContent->setCorpus( + phutil_utf8_convert( + $this->fileContent->getCorpus(), "UTF-8", $try_encoding)); + } + + return $this->fileContent; } final public function getRawData() {