diff --git a/include/api.php b/include/api.php index e7c320e62d..45c9ed2554 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') { @@ -2276,18 +2276,32 @@ $called_api = null; $statushtml = trim(bbcode($body, false, false)); + // Workaround for clients with limited HTML parser functionality $search = array("
", "
", "
", "

", "

", "

", "

", "

", "

", "

", "

", "
", "
", "
", "
"); - $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