mirror of
				https://github.com/dgtlmoon/changedetection.io.git
				synced 2025-10-31 06:37:41 +00:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			update-sto
			...
			elementpat
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | b72ecfa852 | 
| @@ -316,10 +316,11 @@ class ValidateCSSJSONXPATHInput(object): | ||||
|                 if not self.allow_xpath: | ||||
|                     raise ValidationError("XPath not permitted in this field!") | ||||
|                 from lxml import etree, html | ||||
|                 import elementpath | ||||
|                 tree = html.fromstring("<html></html>") | ||||
|  | ||||
|                 try: | ||||
|                     tree.xpath(line.strip()) | ||||
|                     elementpath.select(tree, line) | ||||
|                 except etree.XPathEvalError as e: | ||||
|                     message = field.gettext('\'%s\' is not a valid XPath expression. (%s)') | ||||
|                     raise ValidationError(message % (line, str(e))) | ||||
|   | ||||
| @@ -51,12 +51,13 @@ def element_removal(selectors: List[str], html_content): | ||||
|  | ||||
| # Return str Utf-8 of matched rules | ||||
| def xpath_filter(xpath_filter, html_content, append_pretty_line_formatting=False): | ||||
|     import elementpath | ||||
|     from lxml import etree, html | ||||
|  | ||||
|     tree = html.fromstring(bytes(html_content, encoding='utf-8')) | ||||
|     html_block = "" | ||||
|  | ||||
|     r = tree.xpath(xpath_filter.strip(), namespaces={'re': 'http://exslt.org/regular-expressions'}) | ||||
|     r = elementpath.select(tree, xpath_filter.strip()) | ||||
|     #@note: //title/text() wont work where <title>CDATA.. | ||||
|  | ||||
|     for element in r: | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| import time | ||||
| from flask import url_for | ||||
| from . util import live_server_setup | ||||
| from .util import live_server_setup, wait_for_all_checks | ||||
|  | ||||
| from ..html_tools import * | ||||
|  | ||||
| @@ -164,6 +164,7 @@ def test_check_xpath_text_function_utf8(client, live_server): | ||||
|     assert b'Deleted' in res.data | ||||
|  | ||||
| def test_check_markup_xpath_filter_restriction(client, live_server): | ||||
|     live_server_setup(live_server) | ||||
|     sleep_time_for_fetch_thread = 3 | ||||
|  | ||||
|     xpath_filter = "//*[contains(@class, 'sametext')]" | ||||
| @@ -183,7 +184,7 @@ def test_check_markup_xpath_filter_restriction(client, live_server): | ||||
|     assert b"1 Imported" in res.data | ||||
|  | ||||
|     # Give the thread time to pick it up | ||||
|     time.sleep(sleep_time_for_fetch_thread) | ||||
|     wait_for_all_checks(client) | ||||
|  | ||||
|     # Goto the edit page, add our ignore text | ||||
|     # Add our URL to the import page | ||||
| @@ -195,7 +196,7 @@ def test_check_markup_xpath_filter_restriction(client, live_server): | ||||
|     assert b"Updated watch." in res.data | ||||
|  | ||||
|     # Give the thread time to pick it up | ||||
|     time.sleep(sleep_time_for_fetch_thread) | ||||
|     wait_for_all_checks(client) | ||||
|  | ||||
|     # view it/reset state back to viewed | ||||
|     client.get(url_for("diff_history_page", uuid="first"), follow_redirects=True) | ||||
| @@ -206,7 +207,7 @@ def test_check_markup_xpath_filter_restriction(client, live_server): | ||||
|     # Trigger a check | ||||
|     client.get(url_for("form_watch_checknow"), follow_redirects=True) | ||||
|     # Give the thread time to pick it up | ||||
|     time.sleep(sleep_time_for_fetch_thread) | ||||
|     wait_for_all_checks(client) | ||||
|  | ||||
|     res = client.get(url_for("index")) | ||||
|     assert b'unviewed' not in res.data | ||||
|   | ||||
| @@ -42,6 +42,8 @@ paho-mqtt | ||||
| # (introduced once apprise became a dep) | ||||
| cryptography~=3.4 | ||||
|  | ||||
| elementpath | ||||
|  | ||||
| # Used for CSS filtering | ||||
| beautifulsoup4 | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user