From 1abb261ceaaa30ca2ad8ed14b0162ed81bb4724a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 25 Oct 2025 11:22:09 +0200 Subject: CssXPath: Implement ~ subsequent-sibling (#8154) * CssXPath: Implement ~ Subsequent-sibling fix https://github.com/FreshRSS/FreshRSS/issues/8143 Upstream PR https://github.com/phpgt/CssXPath/pull/231 * Use CssXPath release v1.4.0 https://github.com/phpgt/CssXPath/releases/tag/v1.4.0 --- lib/phpgt/cssxpath/src/Translator.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/phpgt/cssxpath/src') diff --git a/lib/phpgt/cssxpath/src/Translator.php b/lib/phpgt/cssxpath/src/Translator.php index 7bb11265c..e5802fd77 100644 --- a/lib/phpgt/cssxpath/src/Translator.php +++ b/lib/phpgt/cssxpath/src/Translator.php @@ -12,6 +12,7 @@ class Translator { . '|(#(?P[\w-]*))' . '|(\.(?P[\w-]*))' . '|(?P\s*\+\s*)' + . '|(?P\s*~\s*)' . "|(\[(?P[\w-]*)((?P[=~$|^*]+)(?P(.+\[\]'?)|[^\]]+))*\])+" . '|(?P\s+)' . '/'; @@ -24,8 +25,8 @@ class Translator { const EQUALS_STARTS_WITH = "^="; public function __construct( - protected string $cssSelector, - protected string $prefix = ".//", + protected string $cssSelector, + protected string $prefix = ".//", protected bool $htmlMode = true ) { } @@ -198,7 +199,7 @@ class Translator { "[last()]" ); } - break; + break; } break; @@ -235,6 +236,14 @@ class Translator { $hasElement = false; break; + case "subsequentsibling": + array_push( + $xpath, + "/following-sibling::" + ); + $hasElement = false; + break; + case "attribute": if(!$hasElement) { array_push($xpath, "*"); -- cgit v1.2.3