-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when uploading a file to media store #609
Comments
I forgot to mention that, despite of the error, the media file is uploaded nevertheless. |
Hi. Thanks for testing the beta! So what seems to happen here based on the stack trace (I hate that s9y/PHP does truncate that!) is that a string that is too long for a field in the image table gets inserted. The stacktrace references Serendipity/include/functions_images.inc.php Lines 594 to 619 in 5e36b3d
type character varying(5) . There is one of that in the definition of the images table: extension.
Are you trying to upload images that have an extension longer than 5 characters? In any case this is a bug on our side if we are not catching that, but if the file extension is shorter there might be an additional bug in Serendipity/include/functions_images.inc.php Line 584 in 5e36b3d
|
Are you trying to upload images that have an extension longer than 5 characters?
It also crashes for "test.jpg".
|
@AndreasBilke Interesting. I never found anyone using postgresql with Serendipity. Thanks for reporting. Regards, Ian |
@ophian back in the days when I set up the blog, s9y was the only blogging
system I know which supports postgresql. It acutally ran super smooth so
far :)
This issue popped up when I upgraded to debian buster (with newest php and
postgres) and I was therefore "forced" so use the 2.3 beta version of s9y.
I fear that I cannot simply switch from s9y to your Styx edition (with
current db)?
|
Okay, then this is likely indeed related to PHP 7.3. My development installation is sadly stuck on PHP 7.2 so far. @th-h or @yellowled, you ran tests under PHP 7.3, no? Does uploading an image work for you under PHP 7.3 and ends up with the proper extension in the database? |
If that is a question please handle at Styx https://github.com/ophian/styx/issues. Thanks. |
Both our test blogs (current and stable - identical for now) run under PHP 7.3 as of now, if you want to debug that yourself. Uploading of pictures does work there (with mySQL as backend). But now for something completey different (see #618): What doesn't seem to work is selecting one or more images and deleting them via the mass delete button - s9y 2.3.0 (german language) reports "Verzeichnis und Dateien wurden erfolgreich nach verschoben" (yes, with obviously missing target) and does not delete anything ... |
Yes, it works. Tested with GIF, JPG and PNG in s9y 2.3 running on PHP 7.3.5. It seems faster than ever, but that may be my new-ish bandwidth (haven't actually used the blog in a while). |
I can reproduce the error. I added a file called For some reason, in my Right after each upload, a redirect to the media library happens, where the function
In this rather unreadable function, files in the Serendipity/include/functions_images.inc.php Lines 1608 to 1634 in 573fefc
Now I wonder where the file comes from in the first place, why it has this strange suffix, and why it's added to the db when we're just trying to list images?!? |
If I upload a file It seems possible that the name-changing code runs amok and adds '1234' to the extension, but can't reproduce here (2.4-alpha1, i.e. tip of master branch, on PHP 7.3.5. |
At least figured out this part: I manually entered There don't seem to be any checks on allowed extensions when uploading (which is okay, I guess). The file is uploaded correctly. But then when trying to add the image to the DB, an error occurs. I guess the MIME type check correctly identifies the file as an image, regardless of the file extension. The same thing happens when opening the media library: The routine I quoted above looks for files/images that are missing from the DB and tries to add them -> same error. Thumbnail creation fails for such oddly named images, too. In the original issue, there seems to be a file called So, to sum it up: It's not a problem with PostgreSQL (IMHO), but with how S9y handles odd file extension for images and MIME type detection. |
We should just enforce length constraints for the extension, corresponding to the database fields. That would fix this bug and keep the flexibility. |
And keep the otherwise awkward behavior 🤷♂️ But yes, let's implement the length constraint and see what happens. Could be we end up with broken images in the media library, though. |
We could use a larger database field for the extension, but I don't think that makes much sense here; it's good practice to use standardized extension for media. We could try to fix wrong extensions, but that's error prone, and I don't think it's needed - errors like that are rare and easily fixed by the uploader. We could use a whitelist of extensions, but that would limit flexibility. "Media" can be sound files, too (think of podcasting), videos, PDF files ... Lastly, I think it's correct to scan the directory/directories for unknwon files on disk that are not known in the database, as that allows to upload files by FTP (or similar means, like SCP).
Yes, I see. - We'll have to decide: if we check media against a whitelist, we may make it impossible to upload media of other types at all. If we don't, someone may upload files with wrong extensions, but he'll always be able to delete the wrong file and re-upload it. |
I can confirm that the installation where the error occurs has multiple files with weird file extensions. Examples:
Since I host this installation for someone else I can't reconstruct how and when they appeared. |
That's the max length of the extensin database field. Fixes #609. Signed-off-by: Thomas Hochstein <thh@inter.net>
That's the max length of the extension database field. Fixes s9y#609. Signed-off-by: Thomas Hochstein <thh@inter.net>
s9y version: 2.3-beta
PHP version: 7.3.4 (debian buster package)
Postgres version: 11.2 (debian buster package)
When I upload a file to the media store, I get the following error site displayed:
This is not the case for every picture, but for many (I didn't found a pattern).
Putting
$serendipity['production'] = 'debug'
in the config does not help, since then no error is shown at all.The text was updated successfully, but these errors were encountered: