From: Brion Vibber Date: Mon, 22 Mar 2010 19:37:45 +0000 (-0700) Subject: Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=26f49de0dd5673584e734152d2d3329b90eb6978;p=quix0rs-gnu-social.git Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x Conflicts: lib/attachmentlist.php --- 26f49de0dd5673584e734152d2d3329b90eb6978 diff --cc lib/attachmentlist.php index 13dafd13e4,fe38281af9..d29a5fa2fd --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@@ -330,13 -332,8 +330,17 @@@ class Attachment extends AttachmentList $this->out->element('param', array('name' => 'autoStart', 'value' => 1)); $this->out->elementEnd('object'); break; + + case 'text/html': + if ($this->attachment->filename) { + // Locally-uploaded HTML. Scrub and display inline. + $this->showHtmlFile($this->attachment); ++ break; + } - break; ++ // Fall through to default ++ + default: + $this->showFallback(); } } } else { @@@ -364,57 -361,18 +368,71 @@@ } } + 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 '); + } }