[amarok] src/context/engines/wikipedia: Fix crashes on track change (both with Phonon-GStreamer and Phonon-VLC).

Mark Kretschmann kretschmann at kde.org
Wed May 8 10:42:49 UTC 2013


Git commit d13bd61842627ffb2382b5d59a020ea7a5124ca5 by Mark Kretschmann.
Committed on 08/05/2013 at 12:29.
Pushed by markey into branch 'master'.

Fix crashes on track change (both with Phonon-GStreamer and Phonon-VLC).

What happened:

The Wikipedia applet uses QtWebKit for HTML rendering. On
Linux, QtWebKit uses GStreamer for media playback. Turns out that this crashes
with a high probability whenever an <audio> tag is present on a web page. As
music artists' pages often contain audio snippets in Vorbis format, it crashed
a lot when Amarok's applet rendered a page.

The fix:

Removing all audio tags from Wikipedia pages before rendering them in our applet.
Of course, the real fix would have to be done upstream. But until that happens, our
workaround here fixes a shitload of crashes.

We might want to do a 2.7.1 release for Linux, with this patch.

CCMAIL: amarok-devel at kde.org

M  +14   -0    src/context/engines/wikipedia/WikipediaEngine.cpp

http://commits.kde.org/amarok/d13bd61842627ffb2382b5d59a020ea7a5124ca5

diff --git a/src/context/engines/wikipedia/WikipediaEngine.cpp b/src/context/engines/wikipedia/WikipediaEngine.cpp
index 94910e7..0692b8d 100644
--- a/src/context/engines/wikipedia/WikipediaEngine.cpp
+++ b/src/context/engines/wikipedia/WikipediaEngine.cpp
@@ -818,6 +818,20 @@ WikipediaEnginePrivate::wikiParse( QString &wiki )
         }
     }
 
+    { // remove <audio> tags (can lead to crashes in QtWebKit)
+        const QString tag    = QLatin1String("<audio");
+        const QString tagEnd = QLatin1String("</audio>");
+        const int tagEndSize = tagEnd.size();
+        int matchIndex = 0;
+        QStringMatcher tagMatcher( tag );
+        while( (matchIndex = tagMatcher.indexIn(wiki, matchIndex)) != -1 )
+        {
+            const int nToTagEnd = wiki.indexOf( tagEnd, matchIndex ) - matchIndex;
+            QStringRef tagRef = wiki.midRef( matchIndex, nToTagEnd + tagEndSize );
+            wiki.remove( tagRef.toString() );
+        }
+    }
+
     // Adding back style and license information
     wiki = QLatin1String("<div id=\"bodyContent\"") + wiki;
     wiki += copyright;


More information about the Amarok-devel mailing list