mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2025-08-10 16:17:19 +02:00
feed debugger: add content regexp matches to filter debug output
This commit is contained in:
parent
03526d8151
commit
dd6ac57a07
@ -1528,6 +1528,7 @@ class RSSUtils {
|
|||||||
|
|
||||||
foreach ($filter["rules"] as $rule) {
|
foreach ($filter["rules"] as $rule) {
|
||||||
$match = false;
|
$match = false;
|
||||||
|
$regexp_matches = [];
|
||||||
$reg_exp = str_replace('/', '\/', (string)$rule["reg_exp"]);
|
$reg_exp = str_replace('/', '\/', (string)$rule["reg_exp"]);
|
||||||
$reg_exp = str_replace("\n", "", $reg_exp); // reg_exp may be formatted with CRs now because of textarea, we need to strip those
|
$reg_exp = str_replace("\n", "", $reg_exp); // reg_exp may be formatted with CRs now because of textarea, we need to strip those
|
||||||
$rule_inverse = $rule["inverse"] ?? false;
|
$rule_inverse = $rule["inverse"] ?? false;
|
||||||
@ -1538,32 +1539,32 @@ class RSSUtils {
|
|||||||
|
|
||||||
switch ($rule["type"]) {
|
switch ($rule["type"]) {
|
||||||
case "title":
|
case "title":
|
||||||
$match = @preg_match("/$reg_exp/iu", $title);
|
$match = @preg_match("/$reg_exp/iu", $title, $regexp_matches);
|
||||||
break;
|
break;
|
||||||
case "content":
|
case "content":
|
||||||
// we don't need to deal with multiline regexps
|
// we don't need to deal with multiline regexps
|
||||||
$content = (string)preg_replace("/[\r\n\t]/", "", $content);
|
$content = (string)preg_replace("/[\r\n\t]/", "", $content);
|
||||||
|
|
||||||
$match = @preg_match("/$reg_exp/iu", $content);
|
$match = @preg_match("/$reg_exp/iu", $content, $regexp_matches);
|
||||||
break;
|
break;
|
||||||
case "both":
|
case "both":
|
||||||
// we don't need to deal with multiline regexps
|
// we don't need to deal with multiline regexps
|
||||||
$content = (string)preg_replace("/[\r\n\t]/", "", $content);
|
$content = (string)preg_replace("/[\r\n\t]/", "", $content);
|
||||||
|
|
||||||
$match = (@preg_match("/$reg_exp/iu", $title) || @preg_match("/$reg_exp/iu", $content));
|
$match = (@preg_match("/$reg_exp/iu", $title, $regexp_matches) || @preg_match("/$reg_exp/iu", $content, $regexp_matches));
|
||||||
break;
|
break;
|
||||||
case "link":
|
case "link":
|
||||||
$match = @preg_match("/$reg_exp/iu", $link);
|
$match = @preg_match("/$reg_exp/iu", $link, $regexp_matches);
|
||||||
break;
|
break;
|
||||||
case "author":
|
case "author":
|
||||||
$match = @preg_match("/$reg_exp/iu", $author);
|
$match = @preg_match("/$reg_exp/iu", $author, $regexp_matches);
|
||||||
break;
|
break;
|
||||||
case "tag":
|
case "tag":
|
||||||
if (count($tags) == 0)
|
if (count($tags) == 0)
|
||||||
array_push($tags, ''); // allow matching if there are no tags
|
array_push($tags, ''); // allow matching if there are no tags
|
||||||
|
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
if (@preg_match("/$reg_exp/iu", $tag)) {
|
if (@preg_match("/$reg_exp/iu", $tag, $regexp_matches)) {
|
||||||
$match = true;
|
$match = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1589,6 +1590,8 @@ class RSSUtils {
|
|||||||
if ($inverse) $filter_match = !$filter_match;
|
if ($inverse) $filter_match = !$filter_match;
|
||||||
|
|
||||||
if ($filter_match) {
|
if ($filter_match) {
|
||||||
|
$last_processed_rule["regexp_matches"] = $regexp_matches;
|
||||||
|
|
||||||
if (is_array($matched_rules)) array_push($matched_rules, $last_processed_rule);
|
if (is_array($matched_rules)) array_push($matched_rules, $last_processed_rule);
|
||||||
if (is_array($matched_filters)) array_push($matched_filters, $filter);
|
if (is_array($matched_filters)) array_push($matched_filters, $filter);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user