diff --git a/src/bookmarks/backend/default.c b/src/bookmarks/backend/default.c index 2edff74b..94d60b75 100644 --- a/src/bookmarks/backend/default.c +++ b/src/bookmarks/backend/default.c @@ -101,6 +101,8 @@ read_bookmarks_default(FILE *f) root = last_bm->root; } } + /** @todo Bugs 153, 1066: add_bookmark() + * expects UTF-8. */ last_bm = add_bookmark(root, 1, title, url); last_depth = depth; diff --git a/src/bookmarks/backend/xbel.c b/src/bookmarks/backend/xbel.c index ef3ab5a8..0d5be5cb 100644 --- a/src/bookmarks/backend/xbel.c +++ b/src/bookmarks/backend/xbel.c @@ -384,6 +384,8 @@ xbeltree_to_bookmarks_list(struct tree_node *node, title = get_child(node, "title"); href = get_attribute_value(node, "href"); + /** @todo Bugs 153, 1066: add_bookmark() + * expects UTF-8. */ tmp = add_bookmark(current_parent, 0, /* The element is optional */ title && title->text ? title->text @@ -406,6 +408,7 @@ xbeltree_to_bookmarks_list(struct tree_node *node, title = get_child(node, "title"); + /** @todo Bug 153: add_bookmark() expects UTF-8. */ tmp = add_bookmark(current_parent, 0, title && title->text ? title->text : (unsigned char *) gettext("No title"), diff --git a/src/bookmarks/bookmarks.c b/src/bookmarks/bookmarks.c index 07dc28a4..575b695f 100644 --- a/src/bookmarks/bookmarks.c +++ b/src/bookmarks/bookmarks.c @@ -285,6 +285,21 @@ delete_folder_by_name(unsigned char *foldername) } } +/** Allocate and initialize a bookmark in the given folder. This + * however does not set bookmark.box_item; use add_bookmark() for + * that. + * + * @param root + * The folder in which to add the bookmark, or NULL to add it at + * top level. + * @param title + * Title of the bookmark. Must be in UTF-8 and not NULL. + * "-" means add a separator. + * @param url + * URL to which the bookmark will point. Must be in UTF-8. + * NULL or "" means add a bookmark folder. + * + * @return the new bookmark, or NULL on error. */ static struct bookmark * init_bookmark(struct bookmark *root, unsigned char *title, unsigned char *url) { @@ -293,7 +308,6 @@ init_bookmark(struct bookmark *root, unsigned char *title, unsigned char *url) bm = mem_calloc(1, sizeof(*bm)); if (!bm) return NULL; - /** @todo Bug 153: bm->title should be UTF-8 */ bm->title = stracpy(title); if (!bm->title) { mem_free(bm); @@ -301,7 +315,6 @@ init_bookmark(struct bookmark *root, unsigned char *title, unsigned char *url) } sanitize_title(bm->title); - /** @todo Bug 1066: bm->url should be UTF-8 */ bm->url = stracpy(empty_string_or_(url)); if (!bm->url) { mem_free(bm->title); @@ -344,8 +357,21 @@ add_bookmark_item_to_bookmarks(struct bookmark *bm, struct bookmark *root, int p add_hash_item(bookmark_cache, bm->url, strlen(bm->url), bm); } -/* Adds a bookmark to the bookmark list. Place 0 means top, place 1 means - * bottom. NULL or "" @url means it is a bookmark folder. */ +/** Add a bookmark to the bookmark list. + * + * @param root + * The folder in which to add the bookmark, or NULL to add it at + * top level. + * @param place + * 0 means add to the top. 1 means add to the bottom. + * @param title + * Title of the bookmark. Must be in UTF-8 and not NULL. + * "-" means add a separator. + * @param url + * URL to which the bookmark will point. Must be in UTF-8. + * NULL or "" means add a bookmark folder. + * + * @return the new bookmark, or NULL on error. */ struct bookmark * add_bookmark(struct bookmark *root, int place, unsigned char *title, unsigned char *url) @@ -489,6 +515,7 @@ bookmark_terminal(struct terminal *term, struct bookmark *folder) if (!get_current_title(ses, title, MAX_STR_LEN)) continue; + /** @todo Bugs 153, 1066: add_bookmark() expects UTF-8. */ add_bookmark(folder, 1, title, url); } } @@ -496,6 +523,7 @@ bookmark_terminal(struct terminal *term, struct bookmark *folder) void bookmark_terminal_tabs(struct terminal *term, unsigned char *foldername) { + /** @todo Bug 153: add_bookmark() expects UTF-8. */ struct bookmark *folder = add_bookmark(NULL, 1, foldername, NULL); if (!folder) return; @@ -527,6 +555,8 @@ bookmark_all_terminals(struct bookmark *folder) ++n; + /* Because subfoldername[] contains only digits, + * it is OK as UTF-8. */ subfolder = add_bookmark(folder, 1, subfoldername, NULL); if (!subfolder) return; @@ -569,6 +599,7 @@ bookmark_snapshot(void) add_date_to_string(&folderstring, get_opt_str("ui.date_format"), NULL); #endif + /** @todo Bug 153: add_bookmark() expects UTF-8. */ folder = add_bookmark(NULL, 1, folderstring.source, NULL); done_string(&folderstring); if (!folder) return; diff --git a/src/bookmarks/dialogs.c b/src/bookmarks/dialogs.c index af7a4caa..343e3c7b 100644 --- a/src/bookmarks/dialogs.c +++ b/src/bookmarks/dialogs.c @@ -224,6 +224,7 @@ do_add_bookmark(struct dialog_data *dlg_data, unsigned char *title, unsigned cha } } + /** @todo Bugs 153, 1066: add_bookmark() expects UTF-8. */ bm = add_bookmark(bm, 1, title, url); if (!bm) return; diff --git a/src/session/session.c b/src/session/session.c index 99a6ddc7..dead4647 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -969,6 +969,7 @@ init_remote_session(struct session *ses, enum remote_session_flags *remote_ptr, } else if (remote & SES_REMOTE_ADD_BOOKMARK) { #ifdef CONFIG_BOOKMARKS if (!uri) return; + /** @todo Bug 1066: add_bookmark() expects UTF-8. */ add_bookmark(NULL, 1, struri(uri), struri(uri)); #endif