<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>412944</bug_id>
          
          <creation_ts>2019-10-14 17:38:53 +0000</creation_ts>
          <short_desc>Wrong Piwigo version parsing (2.10.x &lt; 2.4) [patch]</short_desc>
          <delta_ts>2019-11-03 18:18:42 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>digikam</product>
          <component>Plugin-WebService-Piwigo</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Eike Rathke">erack</reporter>
          <assigned_to name="Digikam Developers">digikam-bugs-null</assigned_to>
          <cc>caulier.gilles</cc>
    
    <cc>frederic.coiffier</cc>
    
    <cc>mathieu</cc>
          
          <cf_commitlink>https://invent.kde.org/kde/digikam/commit/b08f3555d511a5a8117566dbe9d655af0019ae2c</cf_commitlink>
          <cf_versionfixedin>6.4.0</cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1885414</commentid>
    <comment_count>0</comment_count>
    <who name="Eike Rathke">erack</who>
    <bug_when>2019-10-14 17:38:53 +0000</bug_when>
    <thetext>With a recent Piwigo version 2.10.0 or 2.10.1 the plugin refuses to work, saying

&quot;Failed to login into remote piwigo. Upload to Piwigo version &lt; 2.4 is no longer supported.&quot;

The cause is in ./core/dplugins/generic/webservices/piwigo/piwigotalker.cpp line 487 in PiwigoTalker::parseResponseGetVersion() where the regex

  QRegExp verrx(QLatin1String(&quot;.?(\\d)\\.(\\d).*&quot;));

extracts only two digits (here &apos;2&apos; and &apos;1&apos; of &quot;2.10.1&quot;) that then later in line 509 are calculated as

  d-&gt;version       = qsl[1].toInt() * 10 + qsl[2].toInt();

resulting in 20+1 thus the value 21 which is less than 24.

A correct attempt would be to allow at least 2 (better more) digits for each major.minor, hence

  QRegExp verrx(QLatin1String(&quot;.?(\\d+)\\.(\\d+).*&quot;));

and for example

  d-&gt;version       = qsl[1].toInt() * 1000 + qsl[2].toInt();

that would work with up to 3 digits per minor.

The error occurred also in digikam 5.9.0 Piwigo export kipi plugin.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1885415</commentid>
    <comment_count>1</comment_count>
    <who name="">caulier.gilles</who>
    <bug_when>2019-10-14 17:53:02 +0000</bug_when>
    <thetext>Git commit 402a88c480daf819275470518e1a26c22c9efcd4 by Gilles Caulier.
Committed on 14/10/2019 at 17:55.
Pushed by cgilles into branch &apos;master&apos;.

fix wrong piwigo version parsed by talker
FIXED-IN: 6.4.0

M  +1    -1    core/dplugins/generic/webservices/piwigo/piwigotalker.cpp

https://invent.kde.org/kde/digikam/commit/402a88c480daf819275470518e1a26c22c9efcd4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1885418</commentid>
    <comment_count>2</comment_count>
    <who name="Eike Rathke">erack</who>
    <bug_when>2019-10-14 18:14:32 +0000</bug_when>
    <thetext>Thanks for the fast fix!
While that likely will work, d-&gt;version will not match the proper version though, as it will be calculated as 20+10=30 (which is &gt;24 so that part should be ok), mimicking a 3.0. Just mentioning in case d-&gt;version is used for other purposes as well, I didn&apos;t check; or in future needs to compare against a future version where &quot;3.0&quot; 30 would be less than &quot;2.15&quot; 35 ...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1885494</commentid>
    <comment_count>3</comment_count>
    <who name="Frédéric COIFFIER">frederic.coiffier</who>
    <bug_when>2019-10-15 07:40:17 +0000</bug_when>
    <thetext>Thank you Gilles,

I agree that a change like below could be better (up to 2.100.0 ;-) :

diff --git a/core/dplugins/generic/webservices/piwigo/piwigotalker.cpp b/core/dplugins/generic/webservices/piwigo/piwigotalker.cpp
index 8b75674ddd..eeb915bac0 100644
--- a/core/dplugins/generic/webservices/piwigo/piwigotalker.cpp
+++ b/core/dplugins/generic/webservices/piwigo/piwigotalker.cpp
@@ -506,7 +506,7 @@ void PiwigoTalker::parseResponseGetVersion(const QByteArray&amp; data)
                 if (verrx.exactMatch(v))
                 {
                     QStringList qsl = verrx.capturedTexts();
-                    d-&gt;version       = qsl[1].toInt() * 10 + qsl[2].toInt();
+                    d-&gt;version       = qsl[1].toInt() * 100 + qsl[2].toInt();
                     qCDebug(DIGIKAM_WEBSERVICES_LOG) &lt;&lt; &quot;Version: &quot; &lt;&lt; d-&gt;version;
                     break;
                 }
diff --git a/core/dplugins/generic/webservices/piwigo/piwigotalker.h b/core/dplugins/generic/webservices/piwigo/piwigotalker.h
index 739cf2096e..14e751a920 100644
--- a/core/dplugins/generic/webservices/piwigo/piwigotalker.h
+++ b/core/dplugins/generic/webservices/piwigo/piwigotalker.h
@@ -73,7 +73,7 @@ public:
     enum
     {
         CHUNK_MAX_SIZE = 512*1024,
-        PIWIGO_VER_2_4 = 24
+        PIWIGO_VER_2_4 = 204
     };
 
 public:</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1885519</commentid>
    <comment_count>4</comment_count>
    <who name="">caulier.gilles</who>
    <bug_when>2019-10-15 09:33:10 +0000</bug_when>
    <thetext>Hi Frédéric,

Whole digiKam source code is now migrated to gitlab, and normally your account as developer must be created. You can commit your fix in the the plugin directly.

If your account is not present, we will ask to KDE core team to recreate the account.

Best

Gilles Caulier</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886395</commentid>
    <comment_count>5</comment_count>
    <who name="">caulier.gilles</who>
    <bug_when>2019-10-18 14:38:21 +0000</bug_when>
    <thetext>Git commit b08f3555d511a5a8117566dbe9d655af0019ae2c by Gilles Caulier.
Committed on 18/10/2019 at 14:37.
Pushed by cgilles into branch &apos;master&apos;.

apply patch from Frederic Coiffier about Piwigo version check in digiKam plugin

M  +1    -1    core/dplugins/generic/webservices/piwigo/piwigoplugin.cpp
M  +2    -2    core/dplugins/generic/webservices/piwigo/piwigotalker.cpp
M  +2    -2    core/dplugins/generic/webservices/piwigo/piwigotalker.h

https://invent.kde.org/kde/digikam/commit/b08f3555d511a5a8117566dbe9d655af0019ae2c</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886406</commentid>
    <comment_count>6</comment_count>
    <who name="Eike Rathke">erack</who>
    <bug_when>2019-10-18 15:26:38 +0000</bug_when>
    <thetext>Ah nice, that looks promising :-)

Could both commits be backported to 5.9.0 kipi plugins so that Debian buster and derivates would benefit, and maybe 6.1.0 for Fedora F29 and 6.2.0/6.3.0 for others?

Thanks.
  Eike</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889523</commentid>
    <comment_count>7</comment_count>
    <who name="Mathieu MD">mathieu</who>
    <bug_when>2019-11-03 18:18:42 +0000</bug_when>
    <thetext>(In reply to Eike Rathke from comment #6)
&gt; Could both commits be backported to 5.9.0 kipi plugins so that Debian buster

+1!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>