Skip to content

Commit

Permalink
fix(WebDAV): Fail when trying to sync to XBEL file with html setting …
Browse files Browse the repository at this point in the history
…and vice versa

see #1796

Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Dec 15, 2024
1 parent 9b2f6b9 commit da987b2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"message": "E033: Redirect detected. Please make sure the server supports the selected sync method and URL you entered is correct doesn't redirect to a different location. If the redirect is part of your setup, you can disable this check in the settings."
},
"Error034": {
"message": "E034: Remote bookmarks file is unreadable. Did you forget to set an encryption passphrase?"
"message": "E034: Remote bookmarks file is unreadable. Perhaps you forgot to set an encryption passphrase, or you set the wrong file format."
},
"Error035": {
"message": "E035: Failed to create the following bookmark on the server: {0}"
Expand Down
2 changes: 1 addition & 1 deletion src/errors/Error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class RedirectError extends FloccusError {

export class FileUnreadableError extends FloccusError {
constructor() {
super('E034: Remote bookmarks file is unreadable. Did you forget to set an encryption passphrase?')
super('E034: Remote bookmarks file is unreadable. Perhaps you forgot to set an encryption passphrase, or you set the wrong file format.')
this.code = 34
Object.setPrototypeOf(this, FileUnreadableError.prototype)
}
Expand Down
6 changes: 6 additions & 0 deletions src/lib/adapters/WebDav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,15 @@ export default class WebDavAdapter extends CachingAdapter {

switch (this.server.bookmark_file_type) {
case 'xbel':
if (!xmlDocText.includes('<?xml version="1.0" encoding="UTF-8"?>')) {
throw new FileUnreadableError()
}
this.bookmarksCache = XbelSerializer.deserialize(xmlDocText)
break
case 'html':
if (!xmlDocText.includes('<!DOCTYPE NETSCAPE-Bookmark-file-1>')) {
throw new FileUnreadableError()
}
this.bookmarksCache = Html.deserialize(xmlDocText)
break
default:
Expand Down

0 comments on commit da987b2

Please sign in to comment.