Piwigo / piwigo-flutter-app

Piwigo mobile application for Android
GNU General Public License v2.0
83 stars 26 forks source link

Invalid & escape in URL - Unable to share or download pictures, but video download+share works #190

Open Catfriend1 opened 2 weeks ago

Catfriend1 commented 2 weeks ago

I've made sure all permissions were granted and I selected a write-able directory on my internal storage in both cases.

PiwigoNG: most recent version from GitHub

Log when hitting the share button for a picture:

06-20 15:07:10.750 26225 29452 I flutter : [GET] null
06-20 15:07:10.800 26225 29452 I flutter : [400] null
06-20 15:07:10.800 26225 29452 I flutter : Http status error [400]
06-20 15:07:10.800 26225 29452 I flutter : Instance of 'ResponseBody'
06-20 15:07:10.800 26225 29452 I flutter : null
06-20 15:07:10.800 26225 29452 I flutter : Download images: Http status error [400]
06-20 15:07:10.800 26225 29452 I flutter : []

Log when hitting the share button for a video:

06-20 15:19:34.595 22017 22046 I flutter : [Instance of 'XFile']

The URL in question according to the nginx log is: https://(server):(port)/action.php?id=27143&part=e If I open this via Chrome on PC, it works.

I noticed the log saying "amp;" - Conclusion: I think the app has an escaping error here.

IP - - [20/Jun/2024:15:55:56 +0200] "GET /action.php?id=27143&part=e HTTP/1.1" 400 36 "-" "-"

Via Chrome on PC, I can reproduce the error: image

Catfriend1 commented 2 weeks ago

I've found a temporary workaround on the server side (to be used until the app is fixed giving & instead & as query params).

In /var/www/piwigo/action.php

// Custom: Fix Piwigo-NG Android app
if (strpos($_SERVER['QUERY_STRING'], '&part=e') !== false) {
    $_GET['part'] = 'e';
}

// Put code above before this line (l. 73)
if (!isset($_GET['id'])
    or !is_numeric($_GET['id'])
    or !isset($_GET['part'])
    or !in_array($_GET['part'], array('e','r','f') ) )
Catfriend1 commented 2 weeks ago

@remi-martin Could you please take a look? I think this is pretty easy to fix as the app queries pictures with "&part=e" to action.php instead of "&part=e"

remi-martin commented 2 days ago

Looks like I have another issue when I try to share:

I/flutter (13097): [GET] null
I/flutter (13097): [200] null
I/flutter (13097): [Instance of 'XFile']
E/flutter (13097): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method shareFilesWithResult on channel dev.fluttercommunity.plus/share)
E/flutter (13097): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:332:7)
E/flutter (13097): <asynchronous suspension>
E/flutter (13097): #1      MethodChannelShare.shareFilesWithResult (package:share_plus_platform_interface/method_channel/method_channel_share.dart:140:9)
E/flutter (13097): <asynchronous suspension>
E/flutter (13097): 

*Edit: will be fixed with package version upgrade