From 74a9cec22dfb42650488d8a83352519cbe816772 Mon Sep 17 00:00:00 2001 From: Robert Hegner Date: Sun, 11 May 2025 22:31:20 +0200 Subject: [PATCH 1/3] Disable xpath escape --- sagemcom_api/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sagemcom_api/client.py b/sagemcom_api/client.py index fef370d..04a7926 100644 --- a/sagemcom_api/client.py +++ b/sagemcom_api/client.py @@ -404,7 +404,7 @@ async def get_encryption_method(self): max_tries=1, on_backoff=retry_login, ) - async def get_value_by_xpath(self, xpath: str, options: dict | None = None) -> dict: + async def get_value_by_xpath(self, xpath: str, options: dict | None = None, escape_xpath: bool | None = True) -> dict: """ Retrieve raw value from router using XPath. @@ -414,7 +414,7 @@ async def get_value_by_xpath(self, xpath: str, options: dict | None = None) -> d actions = { "id": 0, "method": "getValue", - "xpath": urllib.parse.quote(xpath), + "xpath": urllib.parse.quote(xpath) if escape_xpath else xpath, "options": options if options else {}, } From 42ebbdb9dcfaa4c53735e597334145e6c479f971 Mon Sep 17 00:00:00 2001 From: Robert Hegner Date: Mon, 12 May 2025 07:16:29 +0200 Subject: [PATCH 2/3] Revert "Disable xpath escape" This reverts commit 74a9cec22dfb42650488d8a83352519cbe816772. --- sagemcom_api/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sagemcom_api/client.py b/sagemcom_api/client.py index 04a7926..fef370d 100644 --- a/sagemcom_api/client.py +++ b/sagemcom_api/client.py @@ -404,7 +404,7 @@ async def get_encryption_method(self): max_tries=1, on_backoff=retry_login, ) - async def get_value_by_xpath(self, xpath: str, options: dict | None = None, escape_xpath: bool | None = True) -> dict: + async def get_value_by_xpath(self, xpath: str, options: dict | None = None) -> dict: """ Retrieve raw value from router using XPath. @@ -414,7 +414,7 @@ async def get_value_by_xpath(self, xpath: str, options: dict | None = None, esca actions = { "id": 0, "method": "getValue", - "xpath": urllib.parse.quote(xpath) if escape_xpath else xpath, + "xpath": urllib.parse.quote(xpath), "options": options if options else {}, } From aa18be43257c03603d1e868ef6e6b6dca7d3e530 Mon Sep 17 00:00:00 2001 From: Robert Hegner Date: Mon, 12 May 2025 07:18:25 +0200 Subject: [PATCH 3/3] Cleaner approach to fix get_value_by_xpath --- sagemcom_api/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sagemcom_api/client.py b/sagemcom_api/client.py index fef370d..203153a 100644 --- a/sagemcom_api/client.py +++ b/sagemcom_api/client.py @@ -414,7 +414,7 @@ async def get_value_by_xpath(self, xpath: str, options: dict | None = None) -> d actions = { "id": 0, "method": "getValue", - "xpath": urllib.parse.quote(xpath), + "xpath": urllib.parse.quote(xpath, "/=[]'"), "options": options if options else {}, }