Closed (fixed)
Project:
File (Field) Paths
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
21 Jul 2010 at 19:37 UTC
Updated:
9 May 2013 at 04:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
j0nathan commented+1 for the feature request, and subscribing.
Comment #2
OKKEP commented+1 for request, subscribing.
'cause with custom field names it's impossible to use properly.
Comment #3
wjaspers commentedLooks like we may be able to blow by 255 characters.
I took a look at teh database design, and everything appears to be safe for this fix.
'#type' => 'textfield',to'#type'=>'textarea'.WARNING:
If you're using CKEditor, or any WYSIWYG that replaces textareas, you'll need to turn OFF this field definition.
By ignoring it, you will accidentally get html in your filenames!
My suggested exclusion rule is this:
EDIT:
Tested a retroactive update against ~15 items. Worked like a charm.
Comment #4
wjaspers commentedComment #5
wjaspers commentedFurther testing and development will be needed to prevent filename problems.
I recently discovered if a stray line break ("\n") is present, it will cause FileField_Paths to break your tokenized path. The result is a WARNING when saving your content, and your file will be saved as: <file-name>_n_y.<file-extension>.
Where "n" is the duplication number (0 for first time, 1 for second ... etc), and y (is the duplication of the duplication number). If left unchecked, I presume this could continue exponentially.....
_n_y_n_y_n_y_n_y .... and so on.
Comment #6
j0nathan commentedHi,
I am no DBA nor programmer, but I don't feel comfortable with a textarea when it should be a text field on only one line without HTML. Maybe I'm worrying too much?
Comment #7
wjaspers commentedI don't think its a serious issue. Especially if the module maintainer filters the textarea's contents.
As a MySQL Developer myself, I understand your concern. Basically, you don't want incorrect data slipping into your database. The database field for your FileField_Paths instance is actually of type MediumText, which allots enough space for all of this data anyway.
It has not happened to me--even when I discovered the flaw in my code change. I assume other modules like: FileField (required here anyways), ImageCache or the ImageAPI module catches the filesystem error before committing the change to the database. Instead of saving your mistake, the filename is logically corrected and saved that way instead.
Because Windows, Unix, Linux, etc... filesystems allow 255 (and some longer) filenames, you could really squeeze every character out of your file renames with a textarea. Not to mention, its way easier for site administrators to read!
Maybe the idea is to utilize a textarea, and using another field, replace line breaks ("\n") with your choice of "-","_","+", or other character?
I'd really hope to hear from our illustrious maintainer soon on this!
Comment #8
j0nathan commentedThank you wjaspers for your explanation.
I don't know what to say about your suggestion of using another field. You'd be better than me for this.
I'll wait and see what others will say.
Comment #9
wjaspers commentedSince I didn't know how to create a patch before ... here's the patch now!
Comment #10
decipheredThe correct way to make this change should be to add
'#maxlength' => 512,in filefield_paths.module after line #33, in the same fashion as it is done for the File path, however the field has been increased to 512 characters in my internal development version of the 2.x branch, which I should hopefully release a alpha/beta/dev version within the week.Cheers,
Deciphered.
Comment #11
Golem07 commentedThe problem seems to have become even bigger in the 7.x branch since the tokens are a lot longer now.
A simple token for a user profile takes up 56 characters on my test page (though the actual path would take up less that 10 characters). So in some cases it is nearly impossible to use more than one token for the path.
Comment #12
mostou commentedI assume the addition of "#maxlength" will be to this file for the 7.x branch:
\modules\filefield_paths.inc
I will try and test it out and upload a patch if it works. I have the issue when using tokens for referenced nodes.
Comment #13
mostou commentedAs suggested from Deciphered, maxlength is added.
Comment #14
decipheredFixed and committed.
Thanks.