Warning: Can't synchronize with the repository (Unsupported version control system "svn": "/usr/lib64/libsvn_ra_neon-1.so.0: undefined symbol: svn_compat_wrap_file_rev_handler" ). Look in the Trac log for more information.

Ticket #82 (closed enhancement: fixed)

Opened 2 years ago

Last modified 21 months ago

RTF support for MOTDs

Reported by: humb4b4 Owned by: humb4b4
Priority: trivial Milestone: Unscheduled
Component: gui Version: 1.0rc2
Keywords: Cc:

Description

ventrilo supports RTF in MOTDS:
 http://myventriloserver.com/blog/ventrilo-motd-adding-custom-colors-fonts-and-other-styles

currently mangler displays the raw rtf data which isnt human readable.

server with a RTF MOTD:
87.242.76.222:3871

Attachments

rtfstrip.patch Download (10.0 KB) - added by x87bliss 21 months ago.
Strips RTF encoded MOTDs of RTF markup, to make them human readable.

Change History

Changed 2 years ago by ekilfoil

  • milestone set to Unscheduled

Changed 21 months ago by x87bliss

The RTF in MOTDs must always start with "{\rtf"

As a quick solution to address the readability of RTF MOTDs, you could have Mangler check for this string, and if it exists strip all the non-essential RTF markup.

The syntax for RTF seems pretty simple. Everything is 'grouped' in braces. These braces signify when to push and pop the current 'state' of the reader from a stack. Although for the purposes of just stripping out RTF markup, you don't really need to keep a stack.

There are also 'control words' which each start with a '\'. These words are delimited by any character which is not a letter and not a digit (the convention is to use a space ' ', or the '\' from a following control word). If the delimiter was a '\' then you interpret the next control word. If it was a space ' ', then you ignore that one space. Then any following text until the next '\' or brace should be displayed to the user.

Most importantly for stripping out RTF markup, Microsoft states that RTF readers don't need to interpret every control word; however, they must safely ignore the ones that they don't understand. One specific command that every RTF reader MUST understand is the '\*' control word. This will appear immediately after an opening brace, and everything until the next closing brace must be ignored and discarded.

Finally as a measure of readability the '\par' control word should probably be implemented as it signifies a new line. In addition '\line', '\sect', and '\page' should probably all be interpreted as line breaks as well.

The one thing I don't know is how actual CR\LFs in the RTF text itself are handled. I don't know if they're ignored by the reader or accepted as part of the visible text. Although based on what I've read, I think they should be visible to the user (i.e. not be ignored).

Source:  http://msdn.microsoft.com/en-us/library/aa140277(office.10).aspx

Changed 21 months ago by x87bliss

Strips RTF encoded MOTDs of RTF markup, to make them human readable.

Changed 21 months ago by ekilfoil

  • owner changed from ekilfoil to humb4b4
  • status changed from new to assigned

This feature is screaming to be implemented by you...

Changed 21 months ago by x87bliss

I uploaded a patch for r814

The patch basically checks every MOTD, and if it's not RTF encoded, it just returns without modifying it.

However, if it is RTF encoded, the stripMotdRtf function will parse it and basically remove almost all RTF markup. It correctly processes \tab to '\t'. Then \par, \line, \sect, and \page all are translated to "\r\n".

Finally it also translates the \'hh control word into the appropriate character replacements.

The new string that is created is of type std::string, so it (de)allocation should be handled automatically.

This solution should make all RTF based MOTDs at least human readable. However, I'm sure at some point you'd want to actually support the RTF formatting for eye candy.

Changed 21 months ago by Haxar

That sounds smart.

Changed 21 months ago by humb4b4

  • status changed from assigned to closed
  • resolution set to fixed

thanks, fixed in r834

Note: See TracTickets for help on using tickets.