bugunrtf - Bugs: bug #66330, iconv output flushed too late...

 
 

bug #66330: iconv output flushed too late (patch attached)

Submitter:  None
Submitted:  Sun 13 Oct 2024 02:22:33 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  None Privacy:  Public
Assigned to:  None Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 13 Oct 2024 02:22:33 PM UTC, original submission:  

Given the RTF input "{\rtf{\b h\'e6}}", unrtf fails to make the escaped 0xe6 (æ) bold. The expected output HTML is "<b>hæ</b>", but unrtf writes "<b>h</b>æ". When there are additional unescaped characters after it (or another word, e.g. a dummy "{\*\0}") unrtf produces the expected output.

The issue seems to be that when the hex sequence is parsed, it is written to a buffer that is not flushed until after the attribute end tag has been written. In this minimal example I am able to fix the problem by moving "flush_iconv_input()" a few lines up in convert.c, but I am not sure if I am breaking anything else. I ran tests/test_html.sh and all files were converted successfully. I diffed the output files and, as far as I can see, the only difference between them is that attribute end tags are placed after the escaped characters. In other words, it looks to me like this is a safe change, but I am not 100 % sure.

Patch (for 0.21.10):
--- src/convert.c
+++ src/convert.c
@@ -4503,6 +4503,10 @@
  within_picture = FALSE;
  }

+ // Flush iconv input
+ flush_iconv_input();
+ iconv_cur = 0;
+
  /* Undo font attributes UNLESS we're doing table cells
  * since they would appear between </td> and </tr>.
  */
@@ -4525,10 +4529,6 @@

  attrstack_drop();

- // Flush iconv input
- flush_iconv_input();
- iconv_cur = 0;
-
  // If there is an encoding in the stacks, restore it, else
  // restore default.
  desc = my_iconv_close(desc);

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #56516:  unrtf.diff added by None (497B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-10-13 None Attached File- Added unrtf.diff, #56516

    Back to the top

    Powered by Savane 3.14-650d.
    Corresponding source code