UTF-8 / latin1-fixes

This commit is contained in:
nikolark committed 2014-07-13 17:43:05 +02:00
1 parent b983a43f2c
commit c95bee2501
5 files changed
+17 -9

No files matched your search

+1 -1
View File
@@ -44,7 +44,7 @@ class CryptoHelper
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return utf8_encode(trim($decrypted));
return trim($decrypted);
}
private function hex2bin($hexdata)
+7
View File
@@ -40,6 +40,9 @@ function add_user($data) {
$cols = array_keys($data);
$values = array_values($data);
// FIXME: Decode UTF-8 values... why?
$values = array_map("utf8_decode", $values);
$sth = $conn->autoPrepare("din_user", $cols, DB_AUTOQUERY_INSERT);
$res = $conn->execute($sth, $values);
@@ -115,6 +118,10 @@ function get_user($user_id) {
unset($user['birthdate']);
}
/* FIXME: Double encode fields as utf-8... why? */
foreach($user as $key => $value) {
$user[$key] = utf8_encode($value);
}
return $user;
}
function get_user_id_by_username($username) {
+4 -3
View File
@@ -37,13 +37,14 @@ function test_post_register() {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json '));
curl_setopt($ch, CURLOPT_ENCODING ,"");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=UTF-8'));
$result = curl_exec($ch);
$result = $crypt->decrypt(trim($result));
$decoded_result = json_decode($result);
$decoded_result = (array) json_decode($result);
if(!isset($decoded_result->error)) {
if(isset($decoded_result['birthdate']) && $decoded_result['birthdate'] === "1983-01-01") {
echo "OK";
var_dump($decoded_result);
} else {
+1 -1
View File
@@ -1,5 +1,5 @@
#!/bin/sh
HOST="http://inside.dev"
curl -XPOST -H"Content-type: application/json" --data-binary @testuser.json $HOST/snapporder/api/register.php
curl -XPOST -H"Content-type: application/json; charset=UTF-8" --data-binary @testuser.json $HOST/snapporder/api/register.php
+4 -4
View File
@@ -1,7 +1,7 @@
{
"firstname": "Üve",
"lastname": "Bårdvigsen",
"email": "aaaadadfzooaaa@aaa422asd333a44za.com",
"birthdate": "1985-02-05",
"phone": "+4745199787"
"lastname": "Bårdvigsen Røed",
"email": "aaaabazbasdfbfffaaaaaba@aaa44za.com",
"birthdate": "1983-01-01",
"phone": "+4743989787"
}