Improve BBCode:toPlaintext
- Fix issue where matching literal square brackets were removed with their content - Fix issue where content without line feeds between BBCode tags would end up compacted in plain text - Update extr calls to BBCode::toPlaintext in api
This commit is contained in:
parent
a0f77e1800
commit
c3e3e83a52
|
@ -614,7 +614,7 @@ function api_get_user(App $a, $contact_id = null)
|
|||
'name' => $contact["name"],
|
||||
'screen_name' => (($contact['nick']) ? $contact['nick'] : $contact['name']),
|
||||
'location' => ($contact["location"] != "") ? $contact["location"] : ContactSelector::networkToName($contact['network'], $contact['url']),
|
||||
'description' => HTML::toPlaintext(BBCode::toPlaintext($contact["about"])),
|
||||
'description' => BBCode::toPlaintext($contact["about"]),
|
||||
'profile_image_url' => $contact["micro"],
|
||||
'profile_image_url_https' => $contact["micro"],
|
||||
'profile_image_url_profile_size' => $contact["thumb"],
|
||||
|
@ -693,7 +693,7 @@ function api_get_user(App $a, $contact_id = null)
|
|||
'name' => (($uinfo[0]['name']) ? $uinfo[0]['name'] : $uinfo[0]['nick']),
|
||||
'screen_name' => (($uinfo[0]['nick']) ? $uinfo[0]['nick'] : $uinfo[0]['name']),
|
||||
'location' => $location,
|
||||
'description' => HTML::toPlaintext(BBCode::toPlaintext($description)),
|
||||
'description' => BBCode::toPlaintext($description),
|
||||
'profile_image_url' => $uinfo[0]['micro'],
|
||||
'profile_image_url_https' => $uinfo[0]['micro'],
|
||||
'profile_image_url_profile_size' => $uinfo[0]["thumb"],
|
||||
|
|
|
@ -357,10 +357,7 @@ class BBCode extends BaseObject
|
|||
*/
|
||||
public static function toPlaintext($text, $keep_urls = true)
|
||||
{
|
||||
$naked_text = preg_replace('/\[.+?\]/','', $text);
|
||||
if (!$keep_urls) {
|
||||
$naked_text = preg_replace('#https?\://[^\s<]+[^\s\.\)]#i', '', $naked_text);
|
||||
}
|
||||
$naked_text = HTML::toPlaintext(BBCode::convert($text, false, 0, true), 0, !$keep_urls);
|
||||
|
||||
return $naked_text;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue