Bug 266171

Summary: TabsEngine should add pre-html-tag when displaying tabs from ultimate-guitar.com
Product: [Applications] amarok Reporter: Martin <ich>
Component: Context View/TabsAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: minor CC: rainer.sigle
Priority: NOR    
Version: 2.4-GIT   
Target Milestone: 2.4.1   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In: 2.4.1
Attachments: Adds the <pre> tag.

Description Martin 2011-02-12 23:23:50 UTC
Version:           2.4-GIT (using KDE 4.6.0) 
OS:                Linux

TabsEngine displays the text from ultimate-guitar.com between the <pre>...</pre> tags in a browser. Thus, multiple spaces are reduced to one space which yields chords like

Bm F# 
On a dark desert highway, cool wind in my hair 

(the F# chord should be over "cool")

Solution: the <pre> tag should be added. Patch is attached.

Reproducible: Always
Comment 1 Martin 2011-02-12 23:24:22 UTC
Created attachment 57196 [details]
Adds the <pre> tag.
Comment 2 Myriam Schweingruber 2011-02-16 20:29:24 UTC
Thank you for the patch. Please submit it to http://git.reviewboard.kde.org, you need to get an identity at http://identity.kde.org first.
Comment 3 Rainer Sigle 2011-02-19 14:16:21 UTC
commit 43c3d86dd856a43aa82d567c365c0c4610989673
Author: Rainer Sigle <rainer.sigle@web.de>
Date:   Sat Feb 19 13:25:28 2011 +0100

    Do not remove HTML <pre> and </pre>-tags from tabs-data. Fix for bug 266171.
    
    Thanks to Martin Kunkel for pointing this out!

diff --git a/src/context/engines/tabs/TabsEngine.cpp b/src/context/engines/tabs/TabsEngine.cpp
index 7c893c6..24507c0 100644
--- a/src/context/engines/tabs/TabsEngine.cpp
+++ b/src/context/engines/tabs/TabsEngine.cpp
@@ -326,8 +326,12 @@ TabsEngine::resultUltimateGuitarTab( const KUrl &url, QByteArray data, NetworkAc
     else
         result = QString( data );
 
+    // extract tab title and data
     const QString title = subStringBetween( result, "<strong>", "</strong>");
-    QString tabs = subStringBetween( result, "<pre>", "</pre>" );
+    QRegExp regex = QRegExp( "<pre>.*</pre>", Qt::CaseInsensitive );
+    if( regex.indexIn( result ) == -1 )
+        return;
+    QString tabs = regex.cap();
     tabs.remove( "<span>", Qt::CaseInsensitive );
     tabs.remove( "</span>", Qt::CaseInsensitive );
 
@@ -441,8 +445,12 @@ TabsEngine::resultFretplayTab( const KUrl &url, QByteArray data, NetworkAccessMa
     else
         result = QString( data );
 
+    // extract tab title and data
     QString title = subStringBetween( result, "title\" content=\"", ". Accurate and free" );
-    QString tabs = subStringBetween( result, "<pre>", "</pre>" );
+    QRegExp regex = QRegExp( "<pre>.*</pre>", Qt::CaseInsensitive );
+    if( regex.indexIn( result ) == -1 )
+        return;
+    QString tabs = regex.cap();
     tabs.remove( "<span>", Qt::CaseInsensitive );
     tabs.remove( "</span>", Qt::CaseInsensitive );
Comment 4 Myriam Schweingruber 2011-02-20 22:18:08 UTC
Rainer, to close bugs automatically, please add a new line below your git comment that says

BUG: 266171

else we have to close it manually.