Control: tags -1 patch
Control: forwarded -1 
https://github.com/GothenburgBitFactory/taskwarrior/issues/1852

Hi,

On 16:29 Tue 05 Apr     , Jakub Wilk wrote:
> Package: taskwarrior
> Version: 2.5.1+dfsg-1
> 
> Taskwarrior to truncate non-ASCII descriptions for tasks that have
> annotations:
> 
> $ task add 'Zażółć gęślą jaźń'
> Created task 1.
> 
> $ task 1 info | grep ^Description
> Description   Zażółć gęślą jaźń
> 
> $ task 1 ann muu
> Annotating task 1 'Zażółć gęślą jaźń'.
> Annotated 1 task.
> 
> $ task 1 info | grep ^Description
> Description   Zażółć gęś

The attached patch fixes the issue for me. It all comes down to 
extractLine() mixing display characters and bytes, failing to account 
for multi-byte characters. AFAICT, upstream's new code for 2.6.0[1] is 
not affected by this bug.

Please consider applying the fix and backporting it to a buster stable 
release, as UTF-8 support has been a long-term release goal.

[1] 
https://github.com/GothenburgBitFactory/libshared/blob/eadeda5d170bb513e52cf1a00ec2cc9501077bbf/src/shared.cpp#L293

Regards,
Apollon
From: Apollon Oikonomopoulos <apoi...@debian.org>
Date: Wed, 10 Jul 2019 21:50:29 +0300
Subject: Fix non-ASCII description truncation

Annotated descriptions with non-ASCII characters get truncated, as
outlined in #820108. This happens because extractLine() keeps track of
the line length in terms of displayed characters while using text.substr to
extract lines, failing to account for multi-byte characters (which only
increment line_length by 1).

Fix this by relying on the cursor set by utf8_next_char, rather than
line_length.

Closes: #820108
---
 src/text.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/text.cpp b/src/text.cpp
index f5e3496..89f3b78 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -248,7 +248,7 @@ bool extractLine (
     // Premature EOL.
     if (character == '\n')
     {
-      line = text.substr (offset, line_length);
+      line = text.substr (offset, cursor - offset - 1);
       offset = cursor;
       return true;
     }

Reply via email to