After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 674924 - buggy ZERO_WIDTH_SPACE hack, maybe should be dropped?
buggy ZERO_WIDTH_SPACE hack, maybe should be dropped?
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: Views: Icon View
3.4.x
Other Linux
: Normal normal
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-04-27 09:16 UTC by Sebastien Bacher
Modified: 2012-04-27 19:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fixes the parenthesis issues in the defined logic (930 bytes, patch)
2012-04-27 10:12 UTC, Sebastien Bacher
none Details | Review

Description Sebastien Bacher 2012-04-27 09:16:04 UTC
Using nautilus 3.4 on Ubuntu precise we had some wrapping issues in the icon view which turned out to be due to nautilus hacks to insert "zero width space" in labels to help wrapping at the right place

The specific bug we had is that "Install Ubuntu 12.04" would wrap after the point and show
"Install Ubuntu 12.
04"

the code is nautilus-icon-canvas-item.c

#define ZERO_WIDTH_SPACE "\xE2\x80\x8B"

#define ZERO_OR_THREE_DIGITS(p) \
	(!g_ascii_isdigit (*p) || \
	 (g_ascii_isdigit (*(p+1)) && \
	  g_ascii_isdigit (*(p+2))))
...
create_label_layout (NautilusIconCanvasItem *item,

	if (text != NULL) {
		str = g_string_new (NULL);

		for (p = text; *p != '\0'; p++) {
			str = g_string_append_c (str, *p);

			if (*p == '_' || *p == '-' || (*p == '.' && ZERO_OR_THREE_DIGITS (p+1))) {
				/* Ensure that we allow to break after '_' or '.' characters,
				 * if they are not likely to be part of a version information, to
				 * not break wrapping of foobar-0.0.1.
				 * Wrap before IPs and long numbers, though. */
				str = g_string_append (str, ZERO_WIDTH_SPACE);
			}"


There is one "obvious" bug, the define "g_ascii_isdigit (*p)" should be "g_ascii_isdigit (*(p))" instead

the current way ZERO_OR_THREE_DIGITS (p+1) has (*p) become (*p+1), or you want (*(p+1)) there

Fixing that issue resolve the initial bug I described.

Still the ZERO_OR_THREE_DIGITS() hack feels wrong, nothing tell you that IPs will have 3 digits or that version numbers follow the described scheme

I would suggesting drop the define and replace the code this way

-			if (*p == '_' || *p == '-' || (*p == '.' && ZERO_OR_THREE_DIGITS (p+1))) {
+			if (*p == '_' || *p == '-' || (*p == '.' && !g_ascii_isdigit(*(p+1)))) {

if you want to keep the current logic to "help" wrapping
Comment 1 Sebastien Bacher 2012-04-27 09:18:20 UTC
Going further I would suggest dropping that code and all and let normal text wrapping happen

We got another bug on https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/986008 which seems to be due to this code

Screenshot:
https://launchpadlibrarian.net/102651819/Screenshot%201.png

Reproducer:
download https://launchpadlibrarian.net/102969878/Test%20Document%20%E0%B8%A1%E0%B8%B5%E0%B8%A0%E0%B8%B2%E0%B8%A9%E0%B8%B2%E0%B9%84%E0%B8%97%E0%B8%A2-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2.txt


What I wrote on the Ubuntu bug is:

"it seems like the "zero width space" is what is creating the issue, I'm unsure why that's happening though.

One bug I can see is that the code is iterating over char types, and an utf8 non ascii glyph might not fit in a char, so it could insert value in the middle of an utf8 sequence and corrupt it, but that doesn't seem to be what is happening there since the "weird" glyphs are added after "_" and ".""


I'm unsure at this point if the bug is a pango one or something...
Comment 2 Sebastien Bacher 2012-04-27 09:19:27 UTC
Let me know if you want me to open different bugs about the different issues
Comment 3 Sebastien Bacher 2012-04-27 10:12:44 UTC
Created attachment 212945 [details] [review]
fixes the parenthesis issues in the defined logic
Comment 4 Cosimo Cecchi 2012-04-27 19:06:28 UTC
Thanks for the patch, I pushed it to git master and gnome-3-4.
The issue with Thai is either a bug in Pango or in the font used...I can reproduce it here on Fedora 17, but it might use the same font as Ubuntu for Thai. Anyway, it should be investigated further and filed as a separate bug.

I still think we want to keep the current wrap limit to three numeric characters after a dot.