jens-maus / carddav2fb

:notebook: A command-line PHP script allowing to import CardDAV-based VCards (e.g. from 'owncloud') to a phonebook in a AVM FRITZ!Box
The Unlicense
28 stars 19 forks source link

Wrong imageURL when config value for usb_disk is used #36

Open Fensterbank opened 8 years ago

Fensterbank commented 8 years ago

The config example says following:

// base path of USB storage of Fritz!Box under which the path 'FRITZ\fonpix' could be found
// '' -> use internal fritzbox storage
//$config['usb_disk'] = 'Generic-FlashDisk-01';

But in the script while setting the file path in the URL we find this line: $person->addChild("imageURL", $this->config['fritzbox_path'] . $this->config['usb_disk'] . "FRITZ/fonpix/" . basename($photo_file));

If the usb_disk config value is used as proposed (without appending a "/"), imageURL properties like file:///var/media/ftp/Generic-FlashDisk-01FRITZ/fonpix/Foo_f1230.jpg are generated, which cannot work.

This should be fixed in code (I did not check if it's only an XML generation issue or if it affects also the file upload), but could break some existing configurations for users, if they appended an "/" to the config value manually.

Fensterbank commented 8 years ago

Addition: If I use $config['usb_disk'] = 'Generic-FlashDisk-01/'; the correct paths will be written to the uploaded phone book XML file, but uploading to FTP fails while trying to upload to Generic-FlashDisk-01//FRITZ/fonpix/.

If I use $config['usb_disk'] = 'Generic-FlashDisk-01'; uploading to FTP is successful but incorrect paths will be written to the uploaded phone book XML file and the Fritzbox cannot show the pictures.

I don't see any case, where the profile picture upload would work with the current code...