From e701ea96b637bcb8cf21e72e0caa7c82e10e278c Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 31 Aug 2008 19:53:21 +0000 Subject: [PATCH] =?utf8?q?Bug=20550096=20=E2=80=93=20GBookmarkFile=20parse?= =?utf8?q?r=20is=20not=20forward=20compatible?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2008-08-31 Emmanuele Bassi Bug 550096 – GBookmarkFile parser is not forward compatible * glib/gbookmarkfile.c: (parse_bookmark_element), (parse_application_element), (parse_mime_type_element), (parse_icon_element): Relax the attributes checking of the GBookmarkFile parser for the attributes that the desktop bookmark file specification defines and controls. This allows adding new attributes to the existing elements in newer versions without breaking the parser in older ones. svn path=/trunk/; revision=7418 --- ChangeLog | 13 +++++++++++++ glib/gbookmarkfile.c | 33 ++++++--------------------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 881295c8..6614ecc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2008-08-31 Emmanuele Bassi + + Bug 550096 – GBookmarkFile parser is not forward compatible + + * glib/gbookmarkfile.c: + (parse_bookmark_element), (parse_application_element), + (parse_mime_type_element), (parse_icon_element): Relax the + attributes checking of the GBookmarkFile parser for the + attributes that the desktop bookmark file specification + defines and controls. This allows adding new attributes to + the existing elements in newer versions without breaking the + parser in older ones. + 2008-08-28 Ryan Lortie Fixup for test case in previous commit. diff --git a/glib/gbookmarkfile.c b/glib/gbookmarkfile.c index 85aa4041..83ed6e87 100644 --- a/glib/gbookmarkfile.c +++ b/glib/gbookmarkfile.c @@ -728,6 +728,10 @@ parse_bookmark_element (GMarkupParseContext *context, visited = attribute_values[i]; else { + /* bookmark is defined by the XBEL spec, so we need + * to error out if the element has different or + * missing attributes + */ g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, _("Unexpected attribute '%s' for element '%s'"), @@ -805,17 +809,9 @@ parse_application_element (GMarkupParseContext *context, stamp = attribute_values[i]; else if (IS_ATTRIBUTE (attr, BOOKMARK_MODIFIED_ATTRIBUTE)) modified = attribute_values[i]; - else - { - g_set_error (error, G_MARKUP_ERROR, - G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, - _("Unexpected attribute '%s' for element '%s'"), - attr, - BOOKMARK_APPLICATION_ELEMENT); - return; - } } + /* the "name" and "exec" attributes are mandatory */ if (!name) { g_set_error (error, G_MARKUP_ERROR, @@ -892,15 +888,6 @@ parse_mime_type_element (GMarkupParseContext *context, { if (IS_ATTRIBUTE (attr, MIME_TYPE_ATTRIBUTE)) type = attribute_values[i]; - else - { - g_set_error (error, G_MARKUP_ERROR, - G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, - _("Unexpected attribute '%s' for element '%s'"), - attr, - MIME_TYPE_ELEMENT); - return; - } } if (!type) @@ -939,17 +926,9 @@ parse_icon_element (GMarkupParseContext *context, href = attribute_values[i]; else if (IS_ATTRIBUTE (attr, BOOKMARK_TYPE_ATTRIBUTE)) type = attribute_values[i]; - else - { - g_set_error (error, G_MARKUP_ERROR, - G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, - _("Unexpected attribute '%s' for element '%s'"), - attr, - BOOKMARK_ICON_ELEMENT); - return; - } } + /* the "href" attribute is mandatory */ if (!href) { g_set_error (error, G_MARKUP_ERROR, -- 2.34.1