|
67 | 67 | PRESENTATION_SUBMISSION_JSONLD_TYPE = "PresentationSubmission" |
68 | 68 | PYTZ_TIMEZONE_PATTERN = re.compile(r"(([a-zA-Z]+)(?:\/)([a-zA-Z]+))") |
69 | 69 | 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 | + |
70 | 73 | LOGGER = logging.getLogger(__name__) |
71 | 74 |
|
72 | 75 |
|
@@ -526,7 +529,9 @@ def reveal_doc(self, credential_dict: dict, constraints: Constraints): |
526 | 529 | if len(match) == 0: |
527 | 530 | continue |
528 | 531 | 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 | + ) |
530 | 535 | if bool(LIST_INDEX_PATTERN.search(full_path)): |
531 | 536 | full_path = re.sub(r"\[(\W+)\]|\[(\d+)\]", "[0]", full_path) |
532 | 537 | full_path = full_path.replace(".[", "[") |
@@ -1601,7 +1606,7 @@ def update_path_recursive_call(path: str, level: int = 0): |
1601 | 1606 | to_check = path_split_array[-1] |
1602 | 1607 | if "." not in to_check: |
1603 | 1608 | 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) |
1605 | 1610 | if len(split_by_index) > 1: |
1606 | 1611 | jsonpath = parse(split_by_index[0]) |
1607 | 1612 | match = jsonpath.find(cred_dict) |
|
0 commit comments