dots in filename

13 years 10 months ago #132320 by ndee
dots in filename was created by ndee
Hi,

if you upload a file with more dots in the filename the first one gets triggered because of using "explode()" to extract the file extension.

steps to reproduce:
1. allow only pdf upload
2. try to upload a pdf with dots in the filename e.g. "testfile-2.3.pdf"
(should be the same behaviour for other extensions)

alert: "Please upload only pdf"

A quick fix (plug_cbfilefield/cb.filefield.php:
about line 124 replace this
[code:1]$uploaded_file = explode( '.', $value );
$uploaded_name = preg_replace( '/[^-a-zA-Z0-9_]/', '', $uploaded_file[0] );
$uploaded_ext = preg_replace( '/[^-a-zA-Z0-9_]/', '', $uploaded_file[1] );[/code:1]
with this:
[code:1]$file_parts = pathinfo($value);
$uploaded_name = preg_replace( '/[^-a-zA-Z0-9_]/', '', $file_parts );
$uploaded_ext = preg_replace( '/[^-a-zA-Z0-9_]/', '', $file_parts );[/code:1]

and about line 207 replace this:
[code:1]$uploaded_file = explode( '.', $value );
$uploaded_ext = preg_replace( '/[^-a-zA-Z0-9_]/', '', $uploaded_file[1] );[/code:1]
with this:
[code:1]$file_parts = pathinfo( $value );
$uploaded_ext = preg_replace( '/[^-a-zA-Z0-9_]/', '', $file_parts );[/code:1]


Greets

Post edited by: ndee, at: 2010/05/05 23:01

Post edited by: ndee, at: 2010/05/05 23:04

###################
SPEED UP HELP, read first: Help us help you
###################

Please Log in to join the conversation.

13 years 10 months ago #132370 by krileon
Replied by krileon on topic Re:dots in filename
Reviewed and applied for next release, thank you for your contribution. :)


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

13 years 10 months ago #132885 by rickconn
Replied by rickconn on topic Re:dots in filename
Thanks for the info.

I can cut and paste your edits, I have shell access, but I have the same error still.

Current version of CB, downloaded two days ago current build of cbplug_cbfilefield_1_0.zip

Im not sure where to go from here.

Thanks.

Please Log in to join the conversation.

13 years 10 months ago #132902 by krileon
Replied by krileon on topic Re:dots in filename
This is fixed for next release; sorry for any inconvenience this has caused you. For time being you should instruct users via fields description to not include periods in the filename.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.220 seconds

Facebook Twitter LinkedIn