Announcement

  •  » Engine
  •  » Proper URL encoding in API responses

#1 2021-11-10 07:08:17

zero0cool
Member
2016-08-14
4

Proper URL encoding in API responses

Greetings!

I noticed that some API calls do not properly URL encode their output. This is specifically becoming a problem when Piwigo is configured with $conf['sync_chars_regex'] to allow filename characters such as a space.

For example, the tn_url attribute returned in pwg.categories.getList contains spaces for image filenames that contain spaces whereas I would expect them to be properly encoded, i.e. a space becomes %20

pwg.categories.getImages behaves in a similar way and URLs of all derivates returned contain spaces.

This currently crashes the Piwigo Mobile application when the sharing extension is called. I submitted a PR, but was sent here instead.

I've tested this both with Piwigo Version 11.5 and 12.0

Offline

 

#2 2021-11-14 19:16:41

cryopad
Piwigo Team
Grenoble, France
2015-11-01
191

Re: Proper URL encoding in API responses

Could you please tell us which plugins do not encode URLs correctly?


If you enjoy Piwigo for iOS…
➤ We would appreciate an AppStore review.
➤ Comments, suggestions ? Tell us on GitHub…
➤ Not yet available in your language ? Help us translate it…

Offline

 

#3 2021-11-15 08:05:56

zero0cool
Member
2016-08-14
4

Re: Proper URL encoding in API responses

My comment wasn't about plugins. Here are the steps to reproduce what happens

1. Install plain vanilla piwigo 12.1.0 - the only plugins installed are those from the installation package and they are all disabled by default

2. Manually (command line) configure $conf['sync_chars_regex'] in local/config/config.inc.php to allow spaces in file names

3. Login as admin and synchronise some images which contain spaces in file names. This succeeds because of step #2

4. Switch to http://mydomain/mypiwigo/tools/ws.htm and run pwg.categories.getImages, i.e. http://mydomain/mypiwigo/ws.php?format=json&method=pwg.categories.getImages&recursive=true

5. Check the output: images[0]->derivatives->square->url looks like "http://mydomain/mypiwigo/i.php?/galleries/2021/21-10-28 08-36-00 8468-sq.jpg"

I would argue the filename part of the url is improperly encoded, and should be

"http://mydomain/mypiwigo/i.php?/galleries/2021/21-10-28%2008-36-00%208468-sq.jpg"

6. Same pattern for all other derivative urls and the element_url property. They are all improperly encoded.

Offline

 

#4 2022-01-09 14:31:12

cryopad
Piwigo Team
Grenoble, France
2015-11-01
191

Re: Proper URL encoding in API responses

Hi zero0cool,

The version 2.9 of the iOS app should fix these issues.


If you enjoy Piwigo for iOS…
➤ We would appreciate an AppStore review.
➤ Comments, suggestions ? Tell us on GitHub…
➤ Not yet available in your language ? Help us translate it…

Offline

 
  •  » Engine
  •  » Proper URL encoding in API responses

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact