Merge pull request #3703 from annando/api-twidere
API: Improvements for clients with bad HTML support
This commit is contained in:
commit
6057dc51f5
|
@ -2233,7 +2233,7 @@ $called_api = null;
|
||||||
|
|
||||||
//don't send title to regular StatusNET requests to avoid confusing these apps
|
//don't send title to regular StatusNET requests to avoid confusing these apps
|
||||||
if (x($_GET, 'getText')) {
|
if (x($_GET, 'getText')) {
|
||||||
$ret['title'] = $item['title'] ;
|
$ret['title'] = $item['title'];
|
||||||
if ($_GET['getText'] == 'html') {
|
if ($_GET['getText'] == 'html') {
|
||||||
$ret['text'] = bbcode($item['body'], false, false);
|
$ret['text'] = bbcode($item['body'], false, false);
|
||||||
} elseif ($_GET['getText'] == 'plain') {
|
} elseif ($_GET['getText'] == 'plain') {
|
||||||
|
@ -2276,18 +2276,32 @@ $called_api = null;
|
||||||
|
|
||||||
$statushtml = trim(bbcode($body, false, false));
|
$statushtml = trim(bbcode($body, false, false));
|
||||||
|
|
||||||
|
// Workaround for clients with limited HTML parser functionality
|
||||||
$search = array("<br>", "<blockquote>", "</blockquote>",
|
$search = array("<br>", "<blockquote>", "</blockquote>",
|
||||||
"<h1>", "</h1>", "<h2>", "</h2>",
|
"<h1>", "</h1>", "<h2>", "</h2>",
|
||||||
"<h3>", "</h3>", "<h4>", "</h4>",
|
"<h3>", "</h3>", "<h4>", "</h4>",
|
||||||
"<h5>", "</h5>", "<h6>", "</h6>");
|
"<h5>", "</h5>", "<h6>", "</h6>");
|
||||||
$replace = array("<br>\n", "\n<blockquote>", "</blockquote>\n",
|
$replace = array("<br>", "<br><blockquote>", "</blockquote><br>",
|
||||||
"\n<h1>", "</h1>\n", "\n<h2>", "</h2>\n",
|
"<br><h1>", "</h1><br>", "<br><h2>", "</h2><br>",
|
||||||
"\n<h3>", "</h3>\n", "\n<h4>", "</h4>\n",
|
"<br><h3>", "</h3><br>", "<br><h4>", "</h4><br>",
|
||||||
"\n<h5>", "</h5>\n", "\n<h6>", "</h6>\n");
|
"<br><h5>", "</h5><br>", "<br><h6>", "</h6><br>");
|
||||||
$statushtml = str_replace($search, $replace, $statushtml);
|
$statushtml = str_replace($search, $replace, $statushtml);
|
||||||
|
|
||||||
if ($item['title'] != "") {
|
if ($item['title'] != "") {
|
||||||
$statushtml = "<h4>" . bbcode($item['title']) . "</h4>\n" . $statushtml;
|
$statushtml = "<br><h4>" . bbcode($item['title']) . "</h4><br>" . $statushtml;
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
$oldtext = $statushtml;
|
||||||
|
$statushtml = str_replace("<br><br>", "<br>", $statushtml);
|
||||||
|
} while ($oldtext != $statushtml);
|
||||||
|
|
||||||
|
if (substr($statushtml, 0, 4) == '<br>') {
|
||||||
|
$statushtml = substr($statushtml, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (substr($statushtml, 0, -4) == '<br>') {
|
||||||
|
$statushtml = substr($statushtml, -4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// feeds without body should contain the link
|
// feeds without body should contain the link
|
||||||
|
|
Loading…
Reference in a new issue