(data)
| 36 | |
| 37 | |
| 38 | def decode_paths(data): |
| 39 | if not data: |
| 40 | return [] # A successful, genuinely empty diff is valid. |
| 41 | if not data.endswith(b'\0'): |
| 42 | raise ValueError('diff is not NUL terminated') |
| 43 | paths = [os.fsdecode(p) for p in data[:-1].split(b'\0')] |
| 44 | if any(not p or p.startswith('/') or any(s in ('.', '..') for s in p.split('/')) |
| 45 | for p in paths): |
| 46 | raise ValueError('invalid repository-relative diff path') |
| 47 | return paths |
| 48 | |
| 49 | |
| 50 | def pr_paths(base, head, cwd=None): |