-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should macOS .webloc files work? #34
Comments
@TomGem Thanks for your bug report. I'll look into that as soon as possible. I'm working on a new version of the app on the |
Thanks for the fast reply! Testing, yes, gladly. How do get the next branch? |
You can download it from this repository (https://github.com/te-online/files_linkeditor/tree/next), but you'll need a testing Nextcloud instance, e.g. on your local machine, because I wouldn't recommend putting the app for testing into your production Nextcloud. On this testing Nextcloud instance you replace the contents of the folder |
@TomGem I've just release version 1.1.0 with the new |
@TomGem That's a shame... Any chance you can send me one of those broken files? Or upload it here? When I create the files in macOS I can open them fine, but I'm not using the latest macOS version, so maybe that's why. |
Of course, I've attached a few to this message: Anyway, current versions of macOS write .webloc files as Apple binary property list: Starting with Mac OS X 10.4, this is the default format for preference files. You might find some hints on how to parse these file here: There is also a command linie utility to convert plist file formats, |
Oh, that's unfortunate 😢 Thanks for your thorough research! I can reproduce this issue now. The funny thing is, that Chrome still uses the XML format, while Safari saves shortcuts in the binary format. What a mess... I'll look into if any of the npm modules will run in the browser, then I can try parsing as XML and if that fails, I'll try to parse the file as binary format. |
…er when appropriate. Addresses #34
The latest release, 1.1.1, addresses this issue by including a binary plist parser. – Two things to note. Firstly, this doubles the bundle size, unfortunately, so I might think about a server-side solution in the future. And, there's no writing of these binary files included. So keep in mind, if you edit a binary plist file it will be replaced by an XML-version of the file. From my experience that works just the same in terms of opening the link on macOS in the future. |
Thank you, I just tested 1.1.1 with various .webloc files, everything works fine now. 👍😊 |
Reporting that the issue persists. |
Generally, binary |
// readbinarywebloc.js
async function fetchResponseValidateSimple (response) {
if (!response.ok) {
return Promise.reject(new Error(response.statusText));
}
return Promise.resolve(response);
}
async function loadDataFromUrlAsArrayBuffer (url) {
return fetch(url)
.then(response => fetchResponseValidateSimple(response) && response.arrayBuffer())
.then(buffer => {return buffer;})
.catch(error => console.error(error?.name, error));
}
// https://stackoverflow.com/a/70765338/1979530
function betweenMarkers (text, begin, end) {
var firstChar = text.indexOf(begin) + begin.length;
var lastChar = text.indexOf(end);
var newText = text.substring(firstChar, lastChar);
return newText;
}
(async () => {
const urlToLoad = 'https://github.com/WARP-LAB/WindowsWeblocOpener/raw/master/testfiles/safari.webloc';
// in Nextcloud app JS side urlToLoad is ->
// const urlToLoad = this.source || this.davPath;
// <- as it would both work in dav (authorized) and plain raw shared cases
const buffer = await loadDataFromUrlAsArrayBuffer(urlToLoad);
// convert to text because albeit plist is binary, the actual url is readable string (see the C impl ;))
const blob = new Blob([buffer], {type: 'text/plain; charset=utf-8'});
const delimStringStart = 'http';
const delimStringEnd = '\b\v';
blob.text().then(
text => {
const urlToOpen = delimStringStart + betweenMarkers(text, delimStringStart, delimStringEnd);
// PROFIT ->
console.log(urlToOpen);
}
);
})() node readbinarywebloc.js p.s. sure, this approach assumes HTTP(S) URI scheme, and ignores any other, but hey... ;) |
Thanks, I'll take a look as soon as I can. Looks promising! |
imho, flag it as not editable and simply do not present user with the option to edit. |
oh, and currently i fall back to just converting binary plists to xml ones in directory trees in those cases where i know that some shared stuff will be accessed by users from web #!/bin/zsh
for f in "$@"
do
PATHT_TO_SEARCH="$f"
echo $PATHT_TO_SEARCH
find $PATHT_TO_SEARCH -name "*.webloc" -exec bash -c "echo '{}' && plutil -convert xml1 '{}'" \;
done
exit 0 |
missed it. yeah, if the url is parsed out from binary, the file could be rewritten using the known scheme and just putting the URL in it <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>URL</key>
<string>URL_RETREIVED_FROM_BINARY_WEBLOC_GOES_HERE</string>
</dict>
</plist> |
Should macOS .webloc files work in the current version? Windows .url files work fine but with any .webloc files NC just says:
This link-file doesn't seem to be valid. – You can fix this by editing the file.
I've attached an example, it's a zipped 'apple binary property list' file.
te-online-files_linkeditor- A nextcloud app to edit .URL and .webloc files and visit links.zip
The text was updated successfully, but these errors were encountered: