From c11064a5398db824f2623c5763b3fdfdf8ae3c39 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 25 Mar 2010 14:15:54 -0700 Subject: Updated 'more' anchor for attachments to do an XHR GET Conflicts: lib/attachmentlist.php plugins/OStatus/classes/Ostatus_profile.php Merge tried to delete things that it seems it shouldn't, very confusing order. Hope rest of the cherry-picking isn't a problem. --- lib/attachmentlist.php | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'lib/attachmentlist.php') diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index b503bfb45..c6261dea5 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -359,6 +359,59 @@ class Attachment extends AttachmentListItem } } + protected function showHtmlFile(File $attachment) + { + $body = $this->scrubHtmlFile($attachment); + if ($body) { + $this->out->raw($body); + } + } + + /** + * @return mixed false on failure, HTML fragment string on success + */ + protected function scrubHtmlFile(File $attachment) + { + $path = File::path($attachment->filename); + if (!file_exists($path) || !is_readable($path)) { + common_log(LOG_ERR, "Missing local HTML attachment $path"); + return false; + } + $raw = file_get_contents($path); + + // Normalize... + $dom = new DOMDocument(); + if(!$dom->loadHTML($raw)) { + common_log(LOG_ERR, "Bad HTML in local HTML attachment $path"); + return false; + } + + // Remove