Skip to content

Commit 79aa5dd

Browse files
authored
Strip trailing dir separator for translated file paths in ITunesLoader (#952)
Fixes #947
1 parent 9875243 commit 79aa5dd

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

dissect/target/loaders/itunes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def translate_file_path(domain: str, relative_path: str) -> str:
290290
package_name = ""
291291

292292
domain_path = fsutil.join(DOMAIN_TRANSLATION.get(domain, domain), package_name)
293-
return fsutil.join(domain_path, relative_path)
293+
return fsutil.join(domain_path, relative_path).rstrip("/")
294294

295295

296296
def parse_key_bag(buf: bytes) -> tuple[dict[str, bytes, int], dict[str, ClassKey]]:

tests/loaders/test_itunes.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import pytest
2+
3+
from dissect.target.loaders.itunes import translate_file_path
4+
5+
6+
@pytest.mark.parametrize(
7+
"domain, relative_path, result",
8+
[
9+
pytest.param(
10+
"HomeDomain",
11+
"Library/Safari/SafariTabs.db",
12+
"/private/var/mobile/Library/Safari/SafariTabs.db",
13+
id="HomeDomain",
14+
),
15+
pytest.param("ProtectedDomain", "", "ProtectedDomain", id="ProtectedDomain"),
16+
pytest.param(
17+
"AppDomain-com.apple.freeform",
18+
"",
19+
"/private/var/mobile/Containers/Data/Application/com.apple.freeform",
20+
id="AppDomain",
21+
),
22+
],
23+
)
24+
def test_translate_file_path(domain: str, relative_path: str, result: str) -> None:
25+
assert translate_file_path(domain, relative_path) == result

0 commit comments

Comments
 (0)