Merge branch 'dev' into 'dev'

use 'cache' flag to bbcode() on content destined for Zot6. We've seen rendered...

See merge request hubzilla/core!1644
This commit is contained in:
Mario 2019-05-11 15:39:31 +02:00
commit a5cd0061c5
2 changed files with 17 additions and 15 deletions

View File

@ -154,7 +154,7 @@ class Activity {
'type' => 'Image', 'type' => 'Image',
'id' => $x['id'], 'id' => $x['id'],
'name' => $x['title'], 'name' => $x['title'],
'content' => bbcode($x['body']), 'content' => bbcode($x['body'], [ 'cache' => true ]),
'source' => [ 'mediaType' => 'text/bbcode', 'content' => $x['body'] ], 'source' => [ 'mediaType' => 'text/bbcode', 'content' => $x['body'] ],
'published' => datetime_convert('UTC','UTC',$x['created'],ATOM_TIME), 'published' => datetime_convert('UTC','UTC',$x['created'],ATOM_TIME),
'updated' => datetime_convert('UTC','UTC', $x['edited'],ATOM_TIME), 'updated' => datetime_convert('UTC','UTC', $x['edited'],ATOM_TIME),
@ -184,11 +184,11 @@ class Activity {
$y = [ $y = [
'type' => 'Event', 'type' => 'Event',
'id' => z_root() . '/event/' . $ev['event_hash'], 'id' => z_root() . '/event/' . $ev['event_hash'],
'summary' => bbcode($ev['summary']), 'summary' => bbcode($ev['summary'], [ 'cache' => true ]),
// RFC3339 Section 4.3 // RFC3339 Section 4.3
'startTime' => (($ev['adjust']) ? datetime_convert('UTC','UTC',$ev['dtstart'], ATOM_TIME) : datetime_convert('UTC','UTC',$ev['dtstart'],'Y-m-d\\TH:i:s-00:00')), 'startTime' => (($ev['adjust']) ? datetime_convert('UTC','UTC',$ev['dtstart'], ATOM_TIME) : datetime_convert('UTC','UTC',$ev['dtstart'],'Y-m-d\\TH:i:s-00:00')),
'content' => bbcode($ev['description']), 'content' => bbcode($ev['description'], [ 'cache' => true ]),
'location' => [ 'type' => 'Place', 'content' => bbcode($ev['location']) ], 'location' => [ 'type' => 'Place', 'content' => bbcode($ev['location'], [ 'cache' => true ]) ],
'source' => [ 'content' => format_event_bbcode($ev), 'mediaType' => 'text/bbcode' ], 'source' => [ 'content' => format_event_bbcode($ev), 'mediaType' => 'text/bbcode' ],
'actor' => $actor, 'actor' => $actor,
]; ];
@ -315,10 +315,10 @@ class Activity {
if($i['mimetype'] === 'text/bbcode') { if($i['mimetype'] === 'text/bbcode') {
if($i['title']) if($i['title'])
$ret['name'] = bbcode($i['title']); $ret['name'] = bbcode($i['title'], [ 'cache' => true ]);
if($i['summary']) if($i['summary'])
$ret['summary'] = bbcode($i['summary']); $ret['summary'] = bbcode($i['summary'], [ 'cache' => true ]);
$ret['content'] = bbcode($i['body']); $ret['content'] = bbcode($i['body'], [ 'cache' => true ]);
$ret['source'] = [ 'content' => $i['body'], 'mediaType' => 'text/bbcode' ]; $ret['source'] = [ 'content' => $i['body'], 'mediaType' => 'text/bbcode' ];
} }
@ -476,14 +476,14 @@ class Activity {
$ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/activity/' . urlencode($i['mid'])); $ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/activity/' . urlencode($i['mid']));
if($i['title']) if($i['title'])
$ret['name'] = html2plain(bbcode($i['title'])); $ret['name'] = html2plain(bbcode($i['title'], [ 'cache' => true ]));
if($i['summary']) if($i['summary'])
$ret['summary'] = bbcode($i['summary']); $ret['summary'] = bbcode($i['summary'], [ 'cache' => true ]);
if($ret['type'] === 'Announce') { if($ret['type'] === 'Announce') {
$tmp = preg_replace('/\[share(.*?)\[\/share\]/ism',EMPTY_STR, $i['body']); $tmp = preg_replace('/\[share(.*?)\[\/share\]/ism',EMPTY_STR, $i['body']);
$ret['content'] = bbcode($tmp); $ret['content'] = bbcode($tmp, [ 'cache' => true ]);
$ret['source'] = [ $ret['source'] = [
'content' => $i['body'], 'content' => $i['body'],
'mediaType' => 'text/bbcode' 'mediaType' => 'text/bbcode'

View File

@ -987,11 +987,13 @@ function bbcode($Text, $options = []) {
// leave open the posibility of [map=something] // leave open the posibility of [map=something]
// this is replaced in prepare_body() which has knowledge of the item location // this is replaced in prepare_body() which has knowledge of the item location
if (strpos($Text,'[/map]') !== false) { if (! $cache) {
$Text = preg_replace_callback("/\[map\](.*?)\[\/map\]/ism", 'bb_map_location', $Text); if (strpos($Text,'[/map]') !== false) {
} $Text = preg_replace_callback("/\[map\](.*?)\[\/map\]/ism", 'bb_map_location', $Text);
if (strpos($Text,'[map=') !== false) { }
$Text = preg_replace_callback("/\[map=(.*?)\]/ism", 'bb_map_coords', $Text); if (strpos($Text,'[map=') !== false) {
$Text = preg_replace_callback("/\[map=(.*?)\]/ism", 'bb_map_coords', $Text);
}
} }
if (strpos($Text,'[map]') !== false) { if (strpos($Text,'[map]') !== false) {
$Text = preg_replace("/\[map\]/", '<div class="map"></div>', $Text); $Text = preg_replace("/\[map\]/", '<div class="map"></div>', $Text);