pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
297 stars 442 forks source link

Plugin upload from the gallery fails if package url contains whitespaces #5255

Open Vitaliy-1 opened 4 years ago

Vitaliy-1 commented 4 years ago

I've encountered the problem with downloading the Immersion theme from the plugin gallery (OJS 3.1.2-1). In the logs:

PHP Warning:  copy(
                https://github.com/pkp/immersion/releases/download/1.0.3/immersion-1.0.3.tar.gz
            ): failed to open stream: No such file or directory in /var/www/ojs-3.1.2-1/lib/pkp/classes/file/FileManager.inc.php on line 163

(line breaks preserved) While debugging, I've noticed that copy() method doesn't work correctly if one of the parameters is a string embraced with whitespaces or line breaks: https://github.com/pkp/pkp-lib/blob/master/classes/file/FileManager.inc.php#L181 And this is just the case for the URL, taken from the package tag of the latest Immersion theme release. The content of this element in the plugins.xml contained line breaks after the opening and before the closing tag. @asmecher , as it doesn't affect XML validity, I suggest trimming the package URL (the content of the package tag) before supplying it to the copy method. I haven't explored if this appears in other places.

asmecher commented 4 years ago

@Vitaliy-1, I've removed the whitespaces from the plugin listing on the PKP website -- if we do add whitespace trimming, it'll still leave the problem for users of OJS versions that don't contain that fix. Removing the whitespace on the PKP server will fix it for everyone. But I'll leave this entry open and add a "try me" tag for someone who wants to add the trim call.