Skip to content

Commit 4d40193

Browse files
committed
chore: bump jsonpath-ng to 1.8.0 and fix full_path format
- Update jsonpath-ng from ^1.7.0 to ^1.8.0 - Normalize str(full_path) in reveal_doc: jsonpath-ng 1.8+ uses parentheses (e.g. ((a.b).c)); strip them for unflatten keys - Use maxsplit=1 in re.split to fix deprecation warning Signed-off-by: Patrick St-Louis <patrick.st-louis@opsecid.ca> Made-with: Cursor
1 parent 0341032 commit 4d40193

3 files changed

Lines changed: 12 additions & 25 deletions

File tree

acapy_agent/protocols/present_proof/dif/pres_exch_handler.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
PRESENTATION_SUBMISSION_JSONLD_TYPE = "PresentationSubmission"
6868
PYTZ_TIMEZONE_PATTERN = re.compile(r"(([a-zA-Z]+)(?:\/)([a-zA-Z]+))")
6969
LIST_INDEX_PATTERN = re.compile(r"\[(\W+)\]|\[(\d+)\]")
70+
# jsonpath-ng 1.8+ uses parentheses in str(full_path); normalize to "a.b.c"
71+
JSONPATH_FULL_PATH_PARENS = re.compile(r"[()]")
72+
7073
LOGGER = logging.getLogger(__name__)
7174

7275

@@ -526,7 +529,9 @@ def reveal_doc(self, credential_dict: dict, constraints: Constraints):
526529
if len(match) == 0:
527530
continue
528531
for match_item in match:
529-
full_path = str(match_item.full_path)
532+
full_path = JSONPATH_FULL_PATH_PARENS.sub(
533+
"", str(match_item.full_path)
534+
)
530535
if bool(LIST_INDEX_PATTERN.search(full_path)):
531536
full_path = re.sub(r"\[(\W+)\]|\[(\d+)\]", "[0]", full_path)
532537
full_path = full_path.replace(".[", "[")
@@ -1601,7 +1606,7 @@ def update_path_recursive_call(path: str, level: int = 0):
16011606
to_check = path_split_array[-1]
16021607
if "." not in to_check:
16031608
return path
1604-
split_by_index = re.split(r"\[(\d+)\]", to_check, 1)
1609+
split_by_index = re.split(r"\[(\d+)\]", to_check, maxsplit=1)
16051610
if len(split_by_index) > 1:
16061611
jsonpath = parse(split_by_index[0])
16071612
match = jsonpath.find(cred_dict)

poetry.lock

Lines changed: 4 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ base58 = "~2.1.0"
2525
canonicaljson = "^2.0.0"
2626
ConfigArgParse = "~1.7"
2727
deepmerge = "^2.0"
28-
jsonpath-ng = "^1.7.0"
28+
jsonpath-ng = "^1.8.0"
2929
Markdown = ">=3.7,<3.11"
3030
markupsafe = "^3.0.2"
3131
marshmallow = "~3.26.1"

0 commit comments

Comments
 (0)