Re: [evolution-patches] Patch for failure to define non-ASCII view name of menu



Looks fine to commit.

thanks,
harish

On Thu, 2005-11-24 at 18:57 +0800, Simon.Zheng wrote:
> Hi,
> 
> Here is the bug
> http://bugzilla.gnome.org/show_bug.cgi?id=322311
> 
> Please help me review attached patch.
> 
> 
> When adding new defined view name, an id needs to be generated from the 
> defined name.
> 
> gal_view_generate_string() traverses UTF-8 string and replace character 
> that is neither a alpha nor a numeral to '_'. This traverse is done 
> according to byte order, not character order. As we know, UTF-8 
> character is a multi-byte sequence. Sometimes, the first byte is 
> regarded as a alpha, but the second is not and is replaced as '_'. 
> Obviously, this character is invalid. And then build_menus() can't deal 
> with this kind of invalid strings, so the defined view won't be displayed.
> 
> Therefore, we should traverse the UTF-8 string according to character 
> order.
> 
> Thanks,
> -Simon
> 
> 
> plain text document attachment (define-view-32311.diff)
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/widgets/ChangeLog,v
> retrieving revision 1.139.2.1
> diff -u -p -r1.139.2.1 ChangeLog
> --- ChangeLog	30 Sep 2005 07:39:22 -0000	1.139.2.1
> +++ ChangeLog	24 Nov 2005 10:29:40 -0000
> @@ -1,3 +1,10 @@
> +2005-11-25 Simon Zheng <simon zheng sun com>
> +
> +	* menus/gal-view-collection.c: (gal_view_generate_string):
> +	Fix #322311. Using g_utf8_next_char() to traverses UTF-8
> +	string and replace characters that are neither a alpha nor
> +	a numeral.
> +
>  2005-09-30  Li Yuan  <li yuan sun com>
>  
>  	* menus/gal-define-views-dialog.c:
> Index: menus/gal-view-collection.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/widgets/menus/gal-view-collection.c,v
> retrieving revision 1.32
> diff -u -p -r1.32 gal-view-collection.c
> --- menus/gal-view-collection.c	23 Jun 2005 09:11:09 -0000	1.32
> +++ menus/gal-view-collection.c	24 Nov 2005 10:29:40 -0000
> @@ -107,9 +107,11 @@ gal_view_generate_string (GalViewCollect
>  		ret_val = g_strdup(gal_view_get_title(view));
>  	else
>  		ret_val = g_strdup_printf("%s_%d", gal_view_get_title(view), which);
> -	for (pointer = ret_val; *pointer; pointer++) {
> -		if (!isalnum((guint) *pointer)) {
> -			*pointer = '_';
> +	for (pointer = ret_val; *pointer; pointer = g_utf8_next_char(pointer)) {
> +		if (!g_unichar_isalnum(g_utf8_get_char(pointer))) {
> +			char *ptr = pointer;
> +			for (; ptr < g_utf8_next_char(pointer); *ptr = '_', ptr++)
> +				;
>  		}
>  	}
>  	return ret_val;
> 
> _______________________________________________
> Evolution-patches mailing list
> Evolution-patches gnome org
> http://mail.gnome.org/mailman/listinfo/evolution-patches




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]