]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
correctly purify input for Blog_entry
authorEvan Prodromou <evan@status.net>
Mon, 20 Jun 2011 15:28:46 +0000 (11:28 -0400)
committerEvan Prodromou <evan@status.net>
Mon, 20 Jun 2011 15:28:46 +0000 (11:28 -0400)
plugins/Blog/Blog_entry.php

index 72cee91a792f29e31a1351bae19a823ef9e965c5..f3166f870ad299e4abde7dcd0dc08c9885d639ed 100644 (file)
@@ -114,18 +114,18 @@ class Blog_entry extends Managed_DataObject
         if (is_null($options)) {
             $options = array();
         }
-        
+
         $be             = new Blog_entry();
         $be->id         = (string) new UUID();
         $be->profile_id = $profile->id;
         $be->title      = $title; // Note: not HTML-protected
         $be->content    = self::purify($content);
-        
+
         if (array_key_exists('summary', $options)) {
             $be->summary = self::purify($options['summary']);
         } else {
             // Already purified
-            $be->summary = self::summarize($content);
+            $be->summary = self::summarize($be->content);
         }
 
         // Don't save an identical summary
@@ -176,15 +176,15 @@ class Blog_entry extends Managed_DataObject
                 XMLStringer::estring('a', array('href' => $url,
                                                 'class' => 'blog-entry'),
                                      _('More...'));
-            $content = html_entity_decode(strip_tags($be->summary), ENT_QUOTES, 'UTF-8');
+            $text = html_entity_decode(strip_tags($be->summary), ENT_QUOTES, 'UTF-8');
         } else {
             $options['rendered'] = $be->content;
-            $content = html_entity_decode(strip_tags($be->content), ENT_QUOTES, 'UTF-8');
+            $text = html_entity_decode(strip_tags($be->content), ENT_QUOTES, 'UTF-8');
         }
 
 
-        if (Notice::contentTooLong($content)) {
-            $content = substr($content, 0, Notice::maxContent() - mb_strlen($shortUrl) - 2) .
+        if (Notice::contentTooLong($text)) {
+            $text = substr($text, 0, Notice::maxContent() - mb_strlen($shortUrl) - 2) .
                 '… ' . $shortUrl;
         }
 
@@ -195,7 +195,7 @@ class Blog_entry extends Managed_DataObject
         $source = array_key_exists('source', $options) ?
                                     $options['source'] : 'web';
         
-        $saved = Notice::saveNew($profile->id, $content, $source, $options);
+        $saved = Notice::saveNew($profile->id, $text, $source, $options);
 
         return $saved;
     }
@@ -249,8 +249,11 @@ class Blog_entry extends Managed_DataObject
     static function purify($html)
     {
         require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
+
         $config = array('safe' => 1,
                         'deny_attribute' => 'id,style,on*');
-        return htmLawed($html, $config);
+        $pure = htmLawed($html, $config);
+
+        return $pure;
     }
 }