Merge pull request #7975 from annando/attach-newlines
Fix optical glitch: Replace multiple newlines when replacing attachments
This commit is contained in:
commit
75a62fc9e4
1 changed files with 3 additions and 3 deletions
|
@ -398,15 +398,15 @@ class BBCode extends BaseObject
|
||||||
*/
|
*/
|
||||||
public static function removeAttachment($body, $no_link_desc = false)
|
public static function removeAttachment($body, $no_link_desc = false)
|
||||||
{
|
{
|
||||||
return preg_replace_callback("/\[attachment (.*)\](.*?)\[\/attachment\]/ism",
|
return preg_replace_callback("/\s*\[attachment (.*)\](.*?)\[\/attachment\]\s*/ism",
|
||||||
function ($match) use ($no_link_desc) {
|
function ($match) use ($no_link_desc) {
|
||||||
$attach_data = self::getAttachmentData($match[0]);
|
$attach_data = self::getAttachmentData($match[0]);
|
||||||
if (empty($attach_data['url'])) {
|
if (empty($attach_data['url'])) {
|
||||||
return $match[0];
|
return $match[0];
|
||||||
} elseif (empty($attach_data['title']) || $no_link_desc) {
|
} elseif (empty($attach_data['title']) || $no_link_desc) {
|
||||||
return '[url]' . $attach_data['url'] . "[/url]\n";
|
return "\n[url]" . $attach_data['url'] . "[/url]\n";
|
||||||
} else {
|
} else {
|
||||||
return '[url=' . $attach_data['url'] . ']' . $attach_data['title'] . "[/url]\n";
|
return "\n[url=" . $attach_data['url'] . ']' . $attach_data['title'] . "[/url]\n";
|
||||||
}
|
}
|
||||||
}, $body);
|
}, $body);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue