]> git.wh0rd.org - tt-rss.git/blobdiff - include/rssfuncs.php
get_article_filters: strip newlines from content before matching
[tt-rss.git] / include / rssfuncs.php
index 1e2feb3cba46ed611cdcc548ee35a0bf9d7e3723..d1e9e6e01612ab7398f02a7426951cd8b81c5747 100644 (file)
                                                        '$entry_comments',
                                                        '$num_comments',
                                                        '$entry_author')");
+
+                                       $article_labels = array();
+
                                } else {
                                        // we keep encountering the entry in feeds, so we need to
                                        // update date_updated column so that we don't get horrible
 
                                        db_query($link, "UPDATE ttrss_entries SET date_updated = NOW()
                                                WHERE id = '$base_entry_id'");
+
+                                       $article_labels = get_article_labels($link, $base_entry_id, $owner_uid);
                                }
 
                                // now it should exist, if not - bad luck then
                                                }
                                        }
 
-                                       $article_labels = get_article_labels($link, $entry_ref_id);
-
                                        if (find_article_filter($article_filters, "filter")) {
                                                db_query($link, "COMMIT"); // close transaction in progress
                                                continue;
                                        foreach ($labels as $label) {
                                                $caption = $label["caption"];
 
-                                               if (preg_match("/\b$caption\b/i", "$tags_str $entry_content $entry_title")) {
+                                               if (preg_match("/\b$caption\b/i", "$tags_str " . strip_tags($entry_content) . " $entry_title")) {
                                                        if (!labels_contains_caption($article_labels, $caption)) {
                                                                label_add_article($link, $entry_ref_id, $caption, $owner_uid);
                                                        }
                                        $match = @preg_match("/$reg_exp/i", $title);
                                        break;
                                case "content":
+                                       // we don't need to deal with multiline regexps
+                                       $content = preg_replace("/[\r\n\t]/", "", $content);
+
                                        $match = @preg_match("/$reg_exp/i", $content);
                                        break;
                                case "both":
-                                       $match = (@preg_match("/$reg_exp/i", $title) || @preg_match("/$reg_exp/i", $title));
+                                       // we don't need to deal with multiline regexps
+                                       $content = preg_replace("/[\r\n\t]/", "", $content);
+
+                                       $match = (@preg_match("/$reg_exp/i", $title) || @preg_match("/$reg_exp/i", $content));
                                        break;
                                case "link":
                                        $match = @preg_match("/$reg_exp/i", $link);