Closed (fixed)
Project:
Plup
Version:
7.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Mar 2013 at 02:04 UTC
Updated:
5 May 2023 at 04:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
indigoxela commentedThe latest core security update (drupal-7.20) breaks many image handling modules.
See release notes: https://drupal.org/drupal-7.20-release-notes
The workaround is to set
$conf['image_allow_insecure_derivatives'] = TRUE;in your settings.php until the problem is fixed in plup.
Comment #2
harald_ commentedThis seems a little bit tricky...
Preview picture urls needs to be generated now by image_style_url()
In plup.js we are going the simple way to generate preview URLs:
Drupal.settings.plup.image_style_path + file.target_namehttp://drupal.org/drupal-7.20-release-notes - there are some other contributed modules which have now problems too
My first idea is to port the function image_style_url() and his used functions to JS?
Maybe that is a wrong track.
Comment #3
btopro commentedThis patch addresses the security issue without the need for the insecure workaround. It does this via the plup_plup_file_validation_alter function in which it takes the widget settings into account and uses the correct method of delivery via image_style_url . It's kind of an odd case because it's a thumbnail generated off of a potentially imagecache generated image (which is what the use-case for the issue stems from).
As such, you need to generate the path as if it's a temporary file but then deliver it as if its public (at least in my case, needs testing cause that seems weird to me to do so). I tried this on a production environment and it fixed it but needs additional testing.
Comment #4
markisatacomputer commentedSame issue with 7.21. These changes worked for me. The patch wouldn't apply so I put them in by hand. Here's a rerolled patch for the latest dev release. Thanks btopro!
Comment #5
indigoxela commentedCaution, there are some problems:
I applied patch plup-thumbnails-d20-update-1933596-4.patch to latest dev of plup on Drupal 7.20
1) formerly existing thumbnails aren't visible anymore
2) new thumbnails aren't visible at all
So I updated to Drupal 7.21
Same problem.
Well, almost the same.
I created a new content type for testing with a new image field.
No galleryformatter for this testing type.
1) New thumbnails (first upload) appear - the temporary ones
2) Derivatives (thumbnail, medium...) get eventually created (about 50% in my tests), others are missing (leading to a 403 in apache log)
3) Those derivatives (thumbnails) are missing when re-edit this node
So the patch fixed the problem with temporary thumbnails but introduces a new problem with unreliable derivative creation?
I could be wrong.
Ehm, right, and the patch breaks content that existed before.
Comment #6
btopro commentedhmm... I'm not experiencing that issue and I'm pretty sure the patch is only affecting files on initial save but I could be wrong.
I have public and private files, the file is being saved into private for that widget using plupload. It's possible I currently have it correct for private but incorrect for public, anyone able to do an A/B test of this patch with and without private turned on for a widget / defined at all?
~!Bryan
Comment #7
indigoxela commentedI was pretty surprised, too.
For completeness: the image field files are in public filesystem.
But the problem was reproducible on my Drupal. I resetted plup to 7.x-1.0-alpha1 (and tested), updated to dev (and tested), applied the patch and the problem was there again.
By the way, everything is fine, when I turn on "image_allow_insecure_derivatives". All the missing thumbnails (and other sizes) get created then.
If I turn it off again, the problem comes back when I add images to already existing nodes and to new nodes.
So possibly the actual problem is in the image field?
On the other hand, maybe I should try to reproduce it on a fresh (vanilla) Drupal install. I have many modules active on that test system. Maybe too many.
Comment #8
indigoxela commentedI did some more testing.
My starting point was a different Drupal install (on a different server), a Drupal 7.20 install with plup 7.x-1.0-alpha1.
I created a content type with a plup widget field on Drupal 7.20.
Then I updated plup to dev and patched it.
No derivative creation on Drupal 7.20 with patched plup, only the temporary thumbnails work fine.
So I updated Drupal to version 7.21. Same problem for both, private and public file system.
Image files get uploaded, temporary thumbnails appear, but no files go to files/styles/thumbnail/public/.. or privatefiles/styles/thumbnail/private/..
Then I switched the widget type for one of my testing content types from plup to normal "image".
No thumbs (or medium...) get created for existing files (neither on node view nor on node save). But if I add a new image with the normal upload widget, this single thumbnail gets created immediately.
Until that I never used image_allow_insecure_derivatives on that install.
Then I turned it on and all missing image sizes get created - no re-edit necessary, it all workes fine only by viewing the nodes.
It works on all nodes, the ones created on Drupal 7.20 and 7.21, with any version of plup.
So actually it seems, we have two different problems.
1) the one this issue is about - temporary thumbnail creation
2) derivative creation on node save
The patch plup-thumbnails-d20-update-1933596-4.patch definitely fixes the first problem.
The second one - until now - has not been confirmed by anybody else.
But I could reproduce it on different servers with different Drupal installs.
Comment #9
indigoxela commentedProblem found (second problem, derivative creation). It is bug http://drupal.org/node/1923554 and has absolutely nothing to do with plup.
If I set a subdirectory for the image field, it works fine, if files go directly to the root of public file system, derivatives do not get created.
A quick look at the database shows the difference:
private:///someimage.jpg
or
public:///someimage.jpg
do not work because of the triple slash problem adressed in http://drupal.org/node/1923554
public://subdirtest/anything.jpg works, as there is no triple slash when using a subdirectory.
Comment #10
btopro commentedthat makes sense. I was wondering what the deal was as the patch really was just targeting the routine that creates the temp file. In creation of this patch I can verify that I did have it adding to a sub-directory for file location (private files). Anyone else that can test this in some different random environments cause it seems pretty obscure.
If the issue truly is a core one I think maybe we should hold off on committing this until that's resolved, lest we introduce more potential issues until 22 is out.
Comment #11
larowlanThis worked for me.
Only downside is that the plup module uses Dos\Windows line endings, :( but that's not something this patch introduces.
Comment #12
indigoxela commentedIt is time to separate these two issues, a new on has been created at http://drupal.org/node/1945830
Plup always produces triple slash paths in file_managed database if files go directly to the root of public or private filesystem
Comment #13
btopro commentedSo, what's the status of this issue then if the two are unrelated? Do we wait til the next release of Drupal or wait for the other issue locally to be resolved?
Comment #14
indigoxela commentedHi btopro,
as these two issues are completely independent, we could release the fix for temporary thumbnails.
Four people confirmed, that the patch resolves the problem.
That should be enough for a commit to dev. Is it enough for a release?
Comment #15
btopro commentedDoesn't matter to me so long as it works but if this is getting in I'd recommend posting it to dev and sitting for a bit til the tripple slash issue is resolved, either in core or in this project. I noticed you said it's fixed in drupal dev, maybe wait to commit to full release until after that fix is in the next release of core in a few weeks?
Comment #16
derjochenmeyer commentedPatch does NOT solve the problem (D 7.21).
Comment #17
jmix commentedSame here, patch on #4 doesn't solves the initial thumbnail issue on D7.21.
Thumbs are not generated after upload (but when node is saved and when going back to admin page, then thumbs are visible).
Comment #18
btopro commented#16 and #17 did you JUST reroll the patch or did you see the larger issue with drupal core mentioned in #9. Multiple confirmations of this patch working so hope there's some more details as to what's causing it not to work in your setups.
Comment #19
jmix commentedhi btopro, thanks for answering.
I just applied patch on #4 (is that what you call reroll ? sorry for my bad english...)
When going to issue http://drupal.org/node/1923554 i'm not sure about what i should do ! Should i apply patch on #15 to drupal core ?
[edit] i just tried to apply patch on 15 of http://drupal.org/node/1923554, but still can't have any "temp" thumbs when uploading threw plup. But if i understand what i read above it's a different problem (and i have a subdirectory set for the image field).
Comment #20
jmix commentedOk, it now works for me in 7.21 (patch #3 then patch #4 applied on plup dev version).
Comment #21
sutharsan commentedI can confirm too that the problem does not appear after applying #4 to 7.x HEAD on an Drupal 7.20 and the latest (1.5.6) plupload library. Enough for RTBC? for me it is.
[edit] corrected a typo
Comment #22
dan_metille commentedUnfortunately, for me patch #4 is not working. I'm on Drupal 7.22 with the latest (1.5.7) plupload library.
I did not have Plup installed before on this site, so it looks to me that my problem (thumbnail not visible after upload, but only when re-editing) is really linked to this issue and not the http://drupal.org/node/1923554.
Comment #23
sun-fire commented#3 and #4 are not worked for me (7.22 core version, patches were applyed to latest dev version of Plup module)
Comment #24
sansui commented7.22, patch applied to dev. Files upload but there are no thumbnails until after saving and editing again.
Edit: not sure what changed... but after an hour of fiddling around noticed that thumbs started working on preview.
Edit2: Had enabled http://drupal.org/project/image_allow_insecure_derivatives and this got the thumbs working again. Not exactly ideal... but until there's a solution I guess this will do.
Comment #25
aze2010 commented+++ subscribing
Comment #26
sun-fire commented#24 Worked for me. Thanks.
Comment #27
sutharsan commented#4 uses the temporay url that only exists during upload. Because the file is removed as soon as the image is uploaded, the image using this url can not be displayed.
This patch uses the same method of creating a thumnail, but uses the url of the uploaded file. For performance reasons I moved the database call to a separate function.
Comment #28
attiks commentedFixed typo in instance settings: preview_image_style, not image_style
Comment #29
emcniece commentedAfter implementing #28, the thumbnails worked for a brief, glorious hour. Now after clearing caches and adjusting some seemingly non-related settings (which I cannot recall, srry), I'm back to the missing thumbnail (whether related to this issue or not, unsure) but I've noticed something interesting - the 404'd thumbnail has a malformed path:
http://site.com/sites/default/files/pub/styles//temporary/p17sdnpkifrkv16i2sdjee5nnp4.jpg?itok=jETO7UQb... and more interestingly, when browsing to a different style path in the browser the thumbnail appears:
http://site.com/sites/default/files/pub/styles/thumbnail/temporary/p17sdnpkifrkv16i2sdjee5nnp4.jpg?itok=jETO7UQbDebugging plup.js at line 157:
I have tested the insecure derivatives plugin mentioned in #24 with no visible results. Any hints as to where to search for this missing thumbnail style in the url?
Comment #30
janiskam commentedI was facing the same problem.
Plup is looking for a variable $instance['widget']['settings']['preview_image_style'] on 421st row of plup.module but there is none defined.
Substitute $instance['widget']['settings']['preview_image_style'] with the preferred image style e.g. "thumbnail" to get it operational.
Comment #31
alex.87 commentedSo what is latest working fix?
@janiskam :
What to put instead of that line ?
Comment #32
emcniece commentedjaniskam's solution:
plup.module line 421:
$file->secure_uri = image_style_url($instance['widget']['settings']['preview_image_style'], $file->uri);Replace with this:
$file->secure_uri = image_style_url("thumbnail", $file->uri);Next step is debugging the $instance settings i suppose.
EDIT: DO NOT USE THIS HACK, replace with this line instead (as per #27):
$file->secure_uri = image_style_url($instance['widget']['settings']['image_style'], $file->uri);Comment #33
emcniece commentedHah, go figure.. is #28 actually a typo? Screenshot of dsm($instance) attached -
$instance['widget']['settings']['preview_image_style']is not actually present, while$instance['widget']['settings']['image_style']is.Looks like the patch in #27 is a better choice. Does this have to do with admin vs. theme-side embedding?
Comment #34
attiks commented#28 is working for me, so maybe we should check for both settings?
Comment #35
emcniece commentedYep, definitely. Are you using the upload dialog in your administration theme? Mine was on the public-facing theme.
Comment #36
attiks commentedIt was coming from the filefield_sources module, new patch checks both preview_image_style and image_style
Comment #37
parrapa commentedAfter aplying #27 #28 and #36 I still get the JS error:
Failed to load resource: the server responded with a status of 403 (Forbidden) http://localhost/instance/sites/default/files/styles/thumbnail/temporary/p17spu07dsobb1e5v1sve16qfoi24.jpgand the Drupal error:
Notice: Undefined property: stdClass::$secure_uri in plup_upload_page() (line 411 of C:\xampp\htdocs\ECBWEB_instance_131\sites\all\modules\contributed\plup\plup.module).What I'm doing wrong?
Comment #38
emcniece commented#36 Working perfectly! Thanks attiks.
Comment #39
emcniece commentedparrapa, can you access http://localhost/instance/sites/default/files/styles/thumbnail/temporary... in your browser? I assume that it would give you your sites 403 page.
I don't have a reference to secure_uri on line 411 of my file. Can you share your plup.module file lines 400-425 with us?
Comment #40
parrapa commentedYep.... I get a "Access denied" page when access to http://[...]/thumbnail/temporary/p17spu07dsobb1e5v1sve16qfoi24.jpg
Thanks!!
Comment #41
attiks commentedCan you try with a clean version and only apply patch 36
Comment #42
emcniece commentedquick test version with patch #36: http://pastebin.com/8Z7dQBV3
Comment #43
parrapa commentedI patched on both plup avalable versions (.dev and alpha)
attiks, when you say clean version should I understand the 7.x-1.0-alpha1 version of the module?
I also tried to replace my entire plup.module with the code posted by emcniece in #42 both in dev and alpha versions and things are not getting better.
I have the impression that I'm missing something quite basic....
Could anyone provide a working plup.zip package in order to test if what is failing is my environment?
Comment #44
emcniece commented7.x-1.0-alpha1+5-dev, patched to #36.
Might be crazy, but check your permissions (
/admin/people/permissions#module-plup). Maybe check the settings at/admin/config/media/file-systemas well and make sure your directories are writeable?Comment #45
parrapa commentedThis is annoying...
Permissions: ok
File system: ok
Writeable directories: ok
After installing your package when I go to the node creation form with the plupload widget:
In firefox:
Notice: Undefined property: stdClass::$secure_uri in plup_upload_page() (line 428 of C:\xampp\htdocs\ECBWEB_instance_131\sites\all\modules\contributed\plup\plup.module).
$file->secure_uri = str_replace('system/temporary', variable_get('file_public_path', 'sites/default/files'), $file->secure_uri);The images are uploaded ok, but the preview thumbnails are missing.
In chrome:
There is no drupal notice but nothing happens when I press "Add". No window for select images appear.
I will save some time and do not test with IE ;)
Comment #46
amirtaiar commentedFor me non of the above helped and I still don't see the thumbnail.
The zip at #44 break remove the area to drop the images.
Comment #47
malberts commentedI modified the patch in #36 to remove the first diff section (for the .info file).
This modified patch works for me with the latest dev version of plup (7.x-1.0-alpha1+5-dev) and Drupal (7.22).
Comment #48
aze2010 commented#47 works for me with latest Dev (2013-May-25).
Thank you!!! :-)
Comment #49
dustin bons commentedWorks, no errors, no strange behaviour!
- Dev 2013-May-25
- Drupal 7.22
- Plupload 1.5.7
Comment #50
emcniece commentedNice. Also confirming operation of Dev 2013-May-25 and Plupload 1.5.7 - looking good!
Comment #51
parrapa commented#47 works like a charm on Firefox & Chrome.
The only weird stuff I found is that using IE8 drag'n'drop functionality is not working. I didn't expect less from IE...
Anyway... Good job!
Comment #52
eugene.ilyin commented#47 works very well for me. Thank you!
Please commit it.
Comment #53
pitxels commentedI had to patch #47 manually, works great
please commit
Comment #54
118218 commentedThank you so much emcniece on #44, it works finally with your zipped module.
All my tries to patch have failed until now, although I already repaired this bug in another website. I also tried to installed module folder from the other website (in which I successfully patched plup) but wasn't working on the new site!
Comment #55
b n pandey commentedThanks for your answer in #1.
Comment #56
Anonymous (not verified) commented#47 works like a charm with latest dev (1st October)
Comment #57
kscheirer#47 worked for me. Was a little tough to apply to 7.x-1.0-alpha1 though, so I rerolled it against that version.
Comment #58
jorisx commented#47 worked flawless for me:
- Plup 7.x-1.0-alpha1+5-dev
- Drupal 7.22
- plupload.full.js from Date: 2013-09-23
Optional #1 fox via settings.php, this seems to be the best and quickest fix:
$conf['image_allow_insecure_derivatives'] = TRUE;
in your settings.php until the problem is fixed in plup.
Comment #59
amirtaiar commentedSeems like #47 is the solution though I am getting:
fatal: corrupt patch at line 88
when patching.
This same line cause me an error when tying to manually add the patch.
Comment #60
sutharsan commented@amirtaiar, that line adds a new (empty) line to the end of the plup.module file. Line 68 removes a curly bracket, line 88 adds the same bracket including an end of line character.
Comment #61
amirtaiar commentedI have tried several times and keep getting this same error.
Can you please upload the full module as a zip here until committing?
Thanks
Comment #62
liquidcms commentedi tried latest -dev with patch #47 and it breaks many other js widget on the page (autocomplete, even simple select lists were broken).
i tried with the -alpha version and patch form #57 - applied clean, doesn't break anything; but doesn't seem to fix the issue.
Comment #63
liquidcms commentedsettings.php fix in #1 is only thing that worked for me.
Comment #64
malberts commentedI just applied the patch to the latest dev version (2013-Oct-01) successfully again.
@liquidcms, are you sure the issues in #62 are as a result of this patch? I have it working with autocomplete fields on the same form. I'm not sure how select lists can break.
Comment #65
danreb commentedI also applied the patch #47 in latest dev version and it works fine. I think @liquidcms was having compatibility problem with other module or field type and should be in a new issue. This patch fixed the problem with the thumbnail not showing instantly after upload and it working like a charm after applying the patch so we should set this to RTBC so the maintainer can commit this fixes.
Comment #66
paravibe commentedI created patch from #47 to apply for the latest plup dev (7.x-1.x).
Works fine for Drupal 7.27.
Thanks a lot!
Comment #67
marcoka commentedAs the project page states "Do not post patches. They won't be commited." Poor choice thats why i wont use this module.
Similar:
https://drupal.org/project/multiupload_imagefield_widget
https://drupal.org/project/filefield_sources_plupload
Comment #68
paravibe commentedYes, I know. But maybe this patch will be usefull.
Comment #69
boobaaRerolling against 7.x-1.0-alpha1.
Comment #70
indigoxela commentedHi Booba,
a new patch for an unsupported module? (Have a look at the project information)
Or do you plan to become the new maintainer?
That would be good news for all users who didn't switch to an alternative yet (still more than 8000 according to drupal.org usage statistics!).
Comment #71
stefdewa commentedThumbnails won't show with a multisite setup. This is because it is possible that the site using plup doesn't have permissions to write in the styles map where temporary files are put. Setting a unique temporary file path fixes the problem. Suggested patch is build further on patch from #47.
Comment #72
liquidcms commentedstill something odd going on here:
i applied patch from #47:
- my local dev system now worked correctly
- applied change to centos server; it also now worked
- applied change to another centos server; it still shows the issue
site with the issue has log
access denied on:
http://env.cpp.edu/sites/env.cpp.edu/files/styles/thumbnail/temporary/p1...
- all 3 sites from svn; so code is the same
- i check perms for /files folder on both centos servers and they match (755)
adding $conf['image_allow_insecure_derivatives'] = TRUE; hack to centos site which fails; does fix the issue
Comment #73
shashank5563 commentedI installed 7.x-1.0-alpha1 version.
After that, I changed row 148 of plup.js from:
'<div class="plup-thumb-wrapper"><img src="'+ fileSaved.secure_uri + '" title="'+ Drupal.checkPlain(file.target_name) +'" /></div>' +to:
Then, I Update given function plup.module from:
function plup_plup_file_validation_alter(&$file, &$e)(){}to:
This is work for me
Comment #74
Mr. Red commentedI used patch #68, but that didn't solve the problem.
Then I set
in settings.php and previews earned.
To test this method, I again removed $conf['image_allow_insecure_derivatives'] = TRUE; from settings.php, but previews continued to work.
Comment #75
shashank5563 commented