From f82b4294d859dc13ebaf96c9e24019d368bb724a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Wed, 6 Mar 2019 04:54:56 +0100 Subject: [PATCH] urlwrapper: add support for binary plist webloc files Quite hardcoded but it works. We only support URLs shorter than 256 bytes as it's the only samples I have. --- src/bin/urlwrapper.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/bin/urlwrapper.cpp b/src/bin/urlwrapper.cpp index 9fea225f4a..49aa7a829b 100644 --- a/src/bin/urlwrapper.cpp +++ b/src/bin/urlwrapper.cpp @@ -135,8 +135,18 @@ UrlWrapper::RefsReceived(BMessage* msg) continue; BString contents; BString url; - if (f.ReadAt(0LL, contents.LockBuffer(size), size) < B_OK) + char *buffer = contents.LockBuffer(size); + const char bplist_match[] = "bplist00\xd1\x01\x02SURL_\x10"; + if (f.ReadAt(0LL, buffer, size) < B_OK) continue; + printf("webloc\n"); + if (size > (sizeof(bplist_match) + 2) + && !strncmp(buffer, bplist_match, sizeof(bplist_match) - 1)) { + // binary plist, let's be crude + uint8 len = buffer[sizeof(bplist_match) - 1]; + url.SetTo(buffer + sizeof(bplist_match), len); + *buffer = 0; // make sure we don't try to interpret as xml + } contents.UnlockBuffer(); int state = 0; while (contents.Length()) {