From e18a037fb254cdb462838463e020ae32a6110011 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Sep 2017 05:16:23 +0000 Subject: [PATCH] API: Improvements for clients with bad HTML support --- include/api.php | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/include/api.php b/include/api.php index e7c320e62..3c84f46f7 100644 --- a/include/api.php +++ b/include/api.php @@ -2233,7 +2233,7 @@ $called_api = null; //don't send title to regular StatusNET requests to avoid confusing these apps if (x($_GET, 'getText')) { - $ret['title'] = $item['title'] ; + $ret['title'] = $item['title']; if ($_GET['getText'] == 'html') { $ret['text'] = bbcode($item['body'], false, false); } elseif ($_GET['getText'] == 'plain') { @@ -2280,14 +2280,31 @@ $called_api = null; "

", "

", "

", "

", "

", "

", "

", "

", "
", "
", "
", "
"); - $replace = array("
\n", "\n
", "
\n", - "\n

", "

\n", "\n

", "

\n", - "\n

", "

\n", "\n

", "

\n", - "\n
", "
\n", "\n
", "
\n"); +// $replace = array(" \n
", " \n
", "
\n ", +// " \n

", "

\n ", " \n

", "

\n ", +// " \n

", "

\n ", " \n

", "

\n ", +// " \n
", "
\n ", " \n
", "
\n "); + $replace = array("
", "
", "

", + "

", "


", "

", "


", + "

", "


", "

", "


", + "
", "

", "
", "

"); $statushtml = str_replace($search, $replace, $statushtml); if ($item['title'] != "") { - $statushtml = "

" . bbcode($item['title']) . "

\n" . $statushtml; + $statushtml = "

" . bbcode($item['title']) . "


" . $statushtml; + } + + do { + $oldtext = $statushtml; + $statushtml = str_replace("

", "
", $statushtml); + } while ($oldtext != $statushtml); + + if (substr($statushtml, 0, 4) == '
') { + $statushtml = substr($statushtml, 4); + } + + if (substr($statushtml, 0, -4) == '
') { + $statushtml = substr($statushtml, -4); } // feeds without body should contain the link