[PATCH] fix adding of HTML lyrics in TagDialog's lyrics tab

Martin darklight.xdarklight at googlemail.com
Mon Sep 14 20:51:31 CEST 2009


Hi,

while trying to understand why I could NOT supply HTML
lyrics (in TagDialog's lyrics tab) I found that the
solution is trivial.

the problem was that the lyrics from within
ui->kTextEdit_lyrics were ALWAYS HTML encoded (that
means all HTML tags were escaped)
you might guess it... instead of the HTML output the
user got the plain HTML code presented

here's the explanation for this:
if the user typed "<br>" into the kTextEdit and clicked
"Save..." the followinig happened:

-the text from within the kTextEdit was read
-toHtml() was called on it
 -> that's where the problem really is: toHtml would
    "convert" "<br>" into "&lt;br&gt;"
    so when the user looked at the lyrics in the
    LyricsApplet could see "<br>" - instead of a newline
-lyrics were saved to the track

here's my patch to fix this issue:

diff --git a/src/dialogs/TagDialog.cpp b/src/dialogs/TagDialog.cpp
index 290ded1..c193ed7 100644
--- a/src/dialogs/TagDialog.cpp
+++ b/src/dialogs/TagDialog.cpp
@@ -1316,7 +1316,11 @@ TagDialog::storeTags( const Meta::TrackPtr &track )
         else
         {
             m_storedLyrics.remove( track );
-            m_storedLyrics.insert( track, ui->kTextEdit_lyrics->toHtml() );
+
+            // don't call toHtml() here as it would break
user-supplied HTML code
+            // (since the HTML code would be escaped the plain HTML code would
+            // be shown in the lyrics applet)
+            m_storedLyrics.insert( track,
ui->kTextEdit_lyrics->toPlainText() );
         }
     }
 }

Regards,
Martin


More information about the Amarok-devel mailing list