aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-08-06 03:29:57 -0700
committerfriendica <info@friendica.com>2013-08-06 03:29:57 -0700
commit71347bb9e0c5daca206b0ea32812874e165b7b63 (patch)
tree7985aedbba169de0bc307110eb24c23638e475a8 /include
parent576b815f9b40997e45cd87f3e8e2f373afca1f11 (diff)
downloadvolse-hubzilla-71347bb9e0c5daca206b0ea32812874e165b7b63.tar.gz
volse-hubzilla-71347bb9e0c5daca206b0ea32812874e165b7b63.tar.bz2
volse-hubzilla-71347bb9e0c5daca206b0ea32812874e165b7b63.zip
we've been storing json_encoded structures on disk in several places because it's a lot easier to parse than xml - but OMG do they get mangled - stored as single quoted strings when escaped as if double quoted. We need to use my new function json_decode_plus() wherever we need to parse one of these babies to make sure we get it right. Maybe we should've just used serialize().
Diffstat (limited to 'include')
-rw-r--r--include/conversation.php8
-rw-r--r--include/enotify.php3
-rwxr-xr-xinclude/text.php8
3 files changed, 13 insertions, 6 deletions
diff --git a/include/conversation.php b/include/conversation.php
index fab8da9f9..2d92b37be 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -92,8 +92,8 @@ function item_redir_and_replace_images($body, $images, $cid) {
function localize_item(&$item){
if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){
-
- $obj= json_decode($item['object'],true);
+
+ $obj = json_decode_plus($item['object']);
if($obj['author'] && $obj['author']['link'])
$author_link = get_rel_link($obj['author']['link'],'alternate');
@@ -106,7 +106,7 @@ function localize_item(&$item){
$Bphoto = '';
- switch($obj->type) {
+ switch($obj['type']) {
case ACTIVITY_OBJ_PHOTO:
$post_type = t('photo');
break;
@@ -142,12 +142,10 @@ function localize_item(&$item){
break;
}
-
// If we couldn't parse something useful, don't bother translating.
// We need something better than zid here, probably magic_link(), but it needs writing
if($author_link && $author_name && $item_url) {
-
$author = '[zrl=' . chanlink_url($item['author']['xchan_url']) . ']' . $item['author']['xchan_name'] . '[/zrl]';
$objauthor = '[zrl=' . chanlink_url($author_link) . ']' . $author_name . '[/zrl]';
diff --git a/include/enotify.php b/include/enotify.php
index 440156bb9..a15e42b73 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -50,13 +50,13 @@ function notification($params) {
$additional_mail_header = "";
-
if(array_key_exists('item',$params)) {
// if it's a normal item...
if(array_key_exists('verb',$params['item'])) {
require_once('include/conversation.php');
// localize_item() alters the original item so make a copy first
$i = $params['item'];
+ logger('calling localize');
localize_item($i);
$title = $i['title'];
$body = $i['body'];
@@ -70,6 +70,7 @@ function notification($params) {
$title = $body = '';
}
+
// e.g. "your post", "David's photo", etc.
$possess_desc = t('%s <!item_type!>');
diff --git a/include/text.php b/include/text.php
index 814c564a3..979fd897a 100755
--- a/include/text.php
+++ b/include/text.php
@@ -1717,3 +1717,11 @@ function jindent($json) {
}
+function json_decode_plus($s) {
+
+ $x = json_decode($s,true);
+ if(! $x)
+ $x = json_decode(str_replace(array('\\"','\\\\'),array('"','\\'),$s),true);
+ return $x;
+
+} \ No newline at end of file