From 3c162486e44199448fe2f0e5ad744b5476cc15ec Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Thu, 7 May 2009 09:54:09 +0200 Subject: [PATCH] Fixed crash with non UTF-8 encoded change log. --- src/IDF/Commit.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/IDF/Commit.php b/src/IDF/Commit.php index 6587148..73f8922 100644 --- a/src/IDF/Commit.php +++ b/src/IDF/Commit.php @@ -148,8 +148,19 @@ class IDF_Commit extends Pluf_Model $commit = new IDF_Commit(); $commit->project = $project; $commit->scm_id = $change->commit; - $commit->summary = $change->title; - $commit->fullmessage = $change->full_message; + if (Pluf_Text_UTF8::check($change->title)) { + $commit->summary = $change->title; + $commit->fullmessage = $change->full_message; + } else { + // Not in utf8, so we try to detect the encoding and + // convert accordingly. + $encoding = mb_detect_encoding($change->title, mb_detect_order(), true); + if ($encoding == false) { + $encoding = Pluf_Text_UTF8::detect_cyr_charset($change->title); + } + $commit->summary = mb_convert_encoding($change->title, 'UTF-8', $encoding); + $commit->fullmessage = mb_convert_encoding($change->full_message, 'UTF-8', $encoding); + } $commit->author = $scm->findAuthor($change->author); $commit->origauthor = $change->author; $commit->creation_dtime = $change->date;