]> git.mjollnir.org Git - moodle.git/commitdiff
fixes HTM files parsing
authordiml <diml>
Mon, 7 Apr 2008 20:36:47 +0000 (20:36 +0000)
committerdiml <diml>
Mon, 7 Apr 2008 20:36:47 +0000 (20:36 +0000)
search/documents/physical_htm.php

index 90b8c0100eb9485f4d7a945c07b1a453bdcbd8f0..76d6073dd6901bba5b934b95814894343a38ab96 100644 (file)
@@ -32,14 +32,24 @@ function get_text_for_indexing_htm(&$resource){
         $meta_attributes = $matches[2];
         $suffix = $matches[3];
         if (preg_match('/name="(keywords|description)"/i', $meta_attributes)){
-            preg_match('/content="[^"]+"/i', $meta_attributes, $matches);
-            $text = $prefix.' '.$matches[0].' '.$suffix;
+            preg_match('/content="([^"]+)"/i', $meta_attributes, $matches);
+            $text = $prefix.' '.$matches[1].' '.$suffix;
         }
     }
-    // filter all html tags
-    // $text = clean_text($text, FORMAT_PLAIN);
-    // NOTE : this is done in ResourceSearchDocument __constructor
-    $text = preg_replace("/<!--[^>]*?-->/", '', $text);
+    // brutally filters all html tags
+    $text = preg_replace("/<[^>]*>/", '', $text);
+    $text = preg_replace("/<!--[^>]*-->/", '', $text);
+    $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
+    $text = mb_convert_encoding($text, 'UTF-8', 'AUTO');
+    
+    /*
+    * debug code for tracing input
+    echo "<hr/>";
+    $FILE = fopen("filetrace.log", 'w');
+    fwrite($FILE, $text);
+    fclose($FILE);
+    echo "<hr/>";
+    */
     
     if (!empty($CFG->block_search_limit_index_body)){
         $text = shorten($text, $CFG->block_search_limit_index_body);