[aur-dev] [PATCH] Fix: FS#15526 non-UTF8 character in rpc output

Gergely Imreh imrehg at gmail.com
Wed Sep 9 14:01:54 EDT 2009


Currently AUR does not check the uploaded packages, whether they are
correctly in UTF8 encoding. If there are fields (such as $pkgdesc)
that contain such non-UTF8 characters, the rpc interface chokes on
those fields: even if there's data successfully retrieved from the
database, rpc returns "null".
In an effort to make such errors in the PKGBUILDs debugged more easily,
let's force rpc to have more useful output: try to convert non-UTF8
fields to UTF8. If it's a success, good. Partial success (some characters
showing as \uXXXX) is ok. Failure results in error message printed to that
field.

Signed-off-by: Gergely Imreh <imrehg at gmail.com>
---
 web/lib/aurjson.class.php |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
index 29fc424..3482a79 100644
--- a/web/lib/aurjson.class.php
+++ b/web/lib/aurjson.class.php
@@ -139,6 +139,15 @@ class AurJSON {
         if ( $result && (mysql_num_rows($result) > 0) ) {
             $row = mysql_fetch_assoc($result);
             mysql_free_result($result);
+            foreach($row as $name => $value) {
+                $converted = utf8_encode($value);
+                if ($converted) {
+                    $row[$name] = $converted;
+                }
+                else {
+                    $row[$name] = "[PKGBUILD error: non-UTF8 character]";
+                }
+            }
             return $this->json_results('info', $row);
         }
         else {
-- 
1.6.4.2


More information about the aur-dev mailing list