Skip to content

Commit a4150b9

Browse files
committed
Merge branch 'master' into use-pyppeteerstealth
2 parents df3dae1 + add2c65 commit a4150b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+695
-414
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ updates:
44
directory: /
55
schedule:
66
interval: "weekly"
7+
"caronc/apprise":
8+
versioning-strategy: "increase"
9+
schedule:
10+
interval: "daily"
711
groups:
812
all:
913
patterns:

.github/workflows/test-only.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
echo "run test with unittest"
6060
docker run test-changedetectionio bash -c 'python3 -m unittest changedetectionio.tests.unit.test_notification_diff'
6161
docker run test-changedetectionio bash -c 'python3 -m unittest changedetectionio.tests.unit.test_watch_model'
62+
docker run test-changedetectionio bash -c 'python3 -m unittest changedetectionio.tests.unit.test_jinja2_security'
6263
6364
# All tests
6465
echo "run test with pytest"

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,7 @@ Supports managing the website watch list [via our API](https://changedetection.i
257257
Do you use changedetection.io to make money? does it save you time or money? Does it make your life easier? less stressful? Remember, we write this software when we should be doing actual paid work, we have to buy food and pay rent just like you.
258258

259259

260-
Firstly, consider taking out an officially supported [website change detection subscription](https://changedetection.io?src=github) , even if you don't use it, you still get the warm fuzzy feeling of helping out the project. (And who knows, you might just use it!)
261-
262-
Or directly donate an amount PayPal [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?hosted_button_id=7CP6HR9ZCNDYJ)
263-
264-
Or BTC `1PLFN327GyUarpJd7nVe7Reqg9qHx5frNn`
265-
266-
<img src="https://raw.githubusercontent.com/dgtlmoon/changedetection.io/master/docs/btc-support.png" style="max-width:50%;" alt="Support us!" />
260+
Consider taking out an officially supported [website change detection subscription](https://changedetection.io?src=github) , even if you don't use it, you still get the warm fuzzy feeling of helping out the project. (And who knows, you might just use it!)
267261

268262
## Commercial Support
269263

changedetectionio/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
# Read more https://github.com/dgtlmoon/changedetection.io/wiki
44

5-
__version__ = '0.45.16'
5+
__version__ = '0.45.22'
66

7-
from distutils.util import strtobool
7+
from changedetectionio.strtobool import strtobool
88
from json.decoder import JSONDecodeError
99
import os
10-
#os.environ['EVENTLET_NO_GREENDNS'] = 'yes'
10+
os.environ['EVENTLET_NO_GREENDNS'] = 'yes'
1111
import eventlet
1212
import eventlet.wsgi
1313
import getopt
@@ -175,6 +175,7 @@ def hide_referrer(response):
175175
# proxy_set_header Host "localhost";
176176
# proxy_set_header X-Forwarded-Prefix /app;
177177

178+
178179
if os.getenv('USE_X_SETTINGS'):
179180
logger.info("USE_X_SETTINGS is ENABLED")
180181
from werkzeug.middleware.proxy_fix import ProxyFix

changedetectionio/api/api_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from distutils.util import strtobool
2+
from changedetectionio.strtobool import strtobool
33

44
from flask_expects_json import expects_json
55
from changedetectionio import queuedWatchMetaData

changedetectionio/blueprint/browser_steps/__init__.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313
#
1414

15-
from distutils.util import strtobool
15+
from changedetectionio.strtobool import strtobool
1616
from flask import Blueprint, request, make_response
1717
import os
1818

@@ -84,7 +84,9 @@ def start_browsersteps_session(watch_uuid):
8484
# Tell Playwright to connect to Chrome and setup a new session via our stepper interface
8585
browsersteps_start_session['browserstepper'] = browser_steps.browsersteps_live_ui(
8686
playwright_browser=browsersteps_start_session['browser'],
87-
proxy=proxy)
87+
proxy=proxy,
88+
start_url=datastore.data['watching'][watch_uuid].get('url')
89+
)
8890

8991
# For test
9092
#browsersteps_start_session['browserstepper'].action_goto_url(value="http://example.com?time="+str(time.time()))
@@ -167,11 +169,6 @@ def browsersteps_ui_update():
167169
step_n = int(request.form.get('step_n'))
168170
is_last_step = strtobool(request.form.get('is_last_step'))
169171

170-
if step_operation == 'Goto site':
171-
step_operation = 'goto_url'
172-
step_optional_value = datastore.data['watching'][uuid].get('url')
173-
step_selector = None
174-
175172
# @todo try.. accept.. nice errors not popups..
176173
try:
177174

changedetectionio/blueprint/browser_steps/browser_steps.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from loguru import logger
88

99
from changedetectionio.content_fetchers.base import manage_user_agent
10+
from changedetectionio.safe_jinja import render as jinja_render
1011

1112
# Two flags, tell the JS which of the "Selector" or "Value" field should be enabled in the front end
1213
# 0- off, 1- on
@@ -48,6 +49,10 @@
4849
# ONLY Works in Playwright because we need the fullscreen screenshot
4950
class steppable_browser_interface():
5051
page = None
52+
start_url = None
53+
54+
def __init__(self, start_url):
55+
self.start_url = start_url
5156

5257
# Convert and perform "Click Button" for example
5358
def call_action(self, action_name, selector=None, optional_value=None):
@@ -64,14 +69,12 @@ def call_action(self, action_name, selector=None, optional_value=None):
6469
action_handler = getattr(self, "action_" + call_action_name)
6570

6671
# Support for Jinja2 variables in the value and selector
67-
from jinja2 import Environment
68-
jinja2_env = Environment(extensions=['jinja2_time.TimeExtension'])
6972

7073
if selector and ('{%' in selector or '{{' in selector):
71-
selector = str(jinja2_env.from_string(selector).render())
74+
selector = jinja_render(template_str=selector)
7275

7376
if optional_value and ('{%' in optional_value or '{{' in optional_value):
74-
optional_value = str(jinja2_env.from_string(optional_value).render())
77+
optional_value = jinja_render(template_str=optional_value)
7578

7679
action_handler(selector, optional_value)
7780
self.page.wait_for_timeout(1.5 * 1000)
@@ -88,6 +91,10 @@ def action_goto_url(self, selector=None, value=None):
8891
logger.debug(f"Time to goto URL {time.time()-now:.2f}s")
8992
return response
9093

94+
# Incase they request to go back to the start
95+
def action_goto_site(self, selector=None, value=None):
96+
return self.action_goto_url(value=self.start_url)
97+
9198
def action_click_element_containing_text(self, selector=None, value=''):
9299
if not len(value.strip()):
93100
return
@@ -195,10 +202,11 @@ class browsersteps_live_ui(steppable_browser_interface):
195202

196203
browser_type = os.getenv("PLAYWRIGHT_BROWSER_TYPE", 'chromium').strip('"')
197204

198-
def __init__(self, playwright_browser, proxy=None, headers=None):
205+
def __init__(self, playwright_browser, proxy=None, headers=None, start_url=None):
199206
self.headers = headers or {}
200207
self.age_start = time.time()
201208
self.playwright_browser = playwright_browser
209+
self.start_url = start_url
202210
if self.context is None:
203211
self.connect(proxy=proxy)
204212

changedetectionio/blueprint/check_proxies/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def long_task(uuid, preferred_proxy):
3131
import time
3232
from changedetectionio.content_fetchers import exceptions as content_fetcher_exceptions
3333
from changedetectionio.processors import text_json_diff
34+
from changedetectionio.safe_jinja import render as jinja_render
3435

3536
status = {'status': '', 'length': 0, 'text': ''}
36-
from jinja2 import Environment, BaseLoader
3737

3838
contents = ''
3939
now = time.time()
@@ -64,7 +64,9 @@ def long_task(uuid, preferred_proxy):
6464
status.update({'status': 'OK', 'length': len(contents), 'text': ''})
6565

6666
if status.get('text'):
67-
status['text'] = Environment(loader=BaseLoader()).from_string('{{text|e}}').render({'text': status['text']})
67+
# parse 'text' as text for safety
68+
v = {'text': status['text']}
69+
status['text'] = jinja_render(template_str='{{text|e}}', **v)
6870

6971
status['time'] = "{:.2f}s".format(time.time() - now)
7072

changedetectionio/blueprint/price_data_follower/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
from distutils.util import strtobool
2+
from changedetectionio.strtobool import strtobool
33
from flask import Blueprint, flash, redirect, url_for
44
from flask_login import login_required
55
from changedetectionio.store import ChangeDetectionStore

changedetectionio/blueprint/tags/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ def tags_overview_page():
1212
from .form import SingleTag
1313
add_form = SingleTag(request.form)
1414
sorted_tags = sorted(datastore.data['settings']['application'].get('tags').items(), key=lambda x: x[1]['title'])
15+
16+
from collections import Counter
17+
18+
tag_count = Counter(tag for watch in datastore.data['watching'].values() if watch.get('tags') for tag in watch['tags'])
19+
1520
output = render_template("groups-overview.html",
16-
form=add_form,
1721
available_tags=sorted_tags,
22+
form=add_form,
23+
tag_count=tag_count
1824
)
1925

2026
return output

0 commit comments

Comments
 (0)