View Ticket
Not logged in
Ticket UUID: 8967ea1df4f51af1ad3cbad78e0bcc582c6418b6
Title: i18n, webui: link to tag with non-ascii chars is broken in timeline
Status: Fixed Type: Code_Defect
Severity: Minor Priority:
Subsystem: Resolution: Fixed
Last Modified: 2011-05-31 12:58:03
Version Found In: [ea2698e9c7] 2011-05-27
Description & Comments:
My OS is Windows XP. I've created some simple test repo with one file. If I added the tag with non-ascii chars (using fossil WebUI) to the checkout, it's shown right on the "Timeline" page, the "Tags" page and the checkout page.

Let the tag be пуск (eight bytes: D0-BF-D1-83 D1-81-D0-BA in UTF8). Then links from the two latter pages behave correct: they lead to this url:

http://127.0.0.1:8081/timeline?t=%D0%BF%D1%83%D1%81%D0%BA

But the former link (on "Timeline" page) looks broken (encoded tag name is truncated):

http://127.0.0.1:8081/timeline?r=%D0%BF%D&nd&c=2011-05-29%2000:20:05
We see, that encoded tag name is truncated to eight chars that is the length in bytes of the tag name in UTF8.

Maybe this helps to solve the problem.


anonymous added on 2011-05-29 07:58:37 UTC:
The truncate length of uri-encoded tag seems to be considered right:
There will 21 chars in the same scenario with the tag Очень круто, which is 5 non-ascii chars + space + 5 non-ascii chars = 21 bytes in UTF8.


anonymous claiming to be tsul added on 2011-05-30 17:18:04 UTC:
Also tested on Fedora 12 x86_64 with fossil version [0448438c56] 2011-05-28 18:51:22, same effect.


anonymous claiming to be tsul added on 2011-05-31 06:31:40 UTC:
There is a bug in the timeline.c:www_print_timeline() with a call to blob_appendf: the format specifier '%t' (httpize) is used with the precision of the input string length. But the output string can obviously be larger.

Here is the working solution removing the precision specifier from the '%t':

V:\dvcs\src>fossil info
project-name: Fossil
repository:   R:/distr/lang/dvcs/fossil/fossil.fsl
local-root:   V:/dvcs/
user-home:    C:/Documents and Settings/Tsul/Application Data
project-code: CE59BB9F186226D80E49D1FA2DB29F935CCA0333
server-code:  dde830bac2d739261e1afb9192dd3facad083e62
checkout:     0448438c56d836a8a8261a0dd97bd82f320d832a 2011-05-28 18:51:22 UTC
parent:       6d35cde78d475f86f75746e65b6e37ca71f8406b 2011-05-28 17:56:04 UTC
child:        0e23d0721318eecdfef70e23da71dfb32110ecfb 2011-05-29 07:39:25 UTC
child:        3abab7e177f063e158fea94cfd13ab5d184f6266 2011-05-30 16:46:50 UTC
child:        62284df93a91fbb86ebb66a645891900c559d840 2011-05-30 07:04:26 UTC
tags:         trunk, release
comment:      Release (user: drh)

V:\dvcs\src>fossil diff timeline.c
--- timeline.c
+++ timeline.c
@@ -300,12 +300,12 @@
         blob_zero(&links);
         while( z && z[0] ){
           for(i=0; z[i] && (z[i]!=',' || z[i+1]!=' '); i++){}
           if( zThisTag==0 || memcmp(z, zThisTag, i)!=0 || zThisTag[i]!=0 ){
             blob_appendf(&links,
-                  "<a href=\"%s/timeline?r=%.*t&nd&c=%s\">%.*h</a>%.2s",
-                  g.zTop, i, z, zDate, i, z, &z[i]
+                  "<a href=\"%s/timeline?r=%t&nd&c=%s\">%.*h</a>%.2s",
+                  g.zTop, z, zDate, i, z, &z[i]
             );
           }else{
             blob_appendf(&links, "%.*h", i+2, z);
           }
           if( z[i]==0 ) break;

drh added on 2011-05-31 12:58:03 UTC:
The patch above is incorrect. A correct patch is shown on check-in [e5e6ca46597a50d215fa08a6ef1bd7b7939e3dea].

The following link demonstrates the error:

/timeline?c=2011-05-28+17%3A56%3A04&n=4

I added the "test-%-&-tag" tag to that check-in. The % and & characters on that tag must be escaped when it is used inside HTML, which increases the length of the rendered text. Without the fix, the hyperlink is rendered incorrectly.