Escaping string arguments in i18n

David Faure faure at
Mon Jun 16 10:23:35 BST 2008

On Sunday 15 June 2008, Chusslove Illich wrote:
> > [: Oswald Buddenhagen :]
> > can you please provide some concrete examples? the problems you are
> > describing should not appear in reasonably crafted code usually, so i must
> > be missing something.
> Any filename in rich context will do. E.g, in:
>   "<qt>The template file <b>%1</b> does not exist.</qt>"
> if the filename contains "<...>" substring, and it was not escaped before
> substitution, Qt will eat it.

Isn't the right fix i18n("<qt>The template file <b>%1</b> does not exist.</qt>", Qt::escape(filename))?
I don't see the need for macros that auto-escape, what's wrong with explicit escaping?

David Faure, faure at, sponsored by Trolltech to work on KDE,
Konqueror (, and KOffice (

More information about the kde-core-devel mailing list