Bug 266171 - TabsEngine should add pre-html-tag when displaying tabs from ultimate-guitar.com
Summary: TabsEngine should add pre-html-tag when displaying tabs from ultimate-guitar.com
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Context View/Tabs (show other bugs)
Version: 2.4-GIT
Platform: Compiled Sources Linux
: NOR minor
Target Milestone: 2.4.1
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-12 23:23 UTC by Martin
Modified: 2011-02-20 22:18 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 2.4.1
Sentry Crash Report:


Attachments
Adds the <pre> tag. (662 bytes, patch)
2011-02-12 23:24 UTC, Martin
Details

Note You need to log in before you can comment on or make changes to this bug.
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.