Relationship Graph

Relationship Graph
related to related to child of child of duplicate of duplicate of

View Issue Details

IDProjectCategoryView StatusLast Update
0002992mantisbtbugtrackerpublic2003-12-13 04:39
Reportervboctor Assigned Tovboctor  
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionfixed 
Product Versiongit trunk 
Summary0002992: Unable to attach files to bugs
Description

The handling for file uploads is different between uploading project documents and uploading file attachments. In my case, the current code of uploading bug attachments is now working. It uses gpc_get_file() which doesn't seem to work since it strips the back spashes, and hence, leaving paths as:

C:FIRSTSECONDTHIRDFILE.XXX

rather than

C:\FIRST\SECOND\THIRD\FILE.XXX.

Note that the upload path is specified and it is the same path where the project documents are uploaded.

Additional Information

The error I get is:
APPLICATION ERROR 15: ERROR: File upload failed. PHP file uploads may be disabled. Please ask your admin to run the admin_check script to debug this problem.
(bug_file_add.php: line 33)

TagsNo tags attached.

Relationships

has duplicate 0003013 closedjlatour failing file-upload on windows based solutions 
has duplicate 0003206 closedaarjona Can't join files where reporting a new bug or updating an existing one 
has duplicate 0003235 closedaarjona Can't upload files 

Activities

vboctor

vboctor

2003-02-23 05:42

manager   ~0003790

Actually, I tested again the file upload to project, and I got the following error:

APPLICATION ERROR 401: ERROR: Database query failed.
(database_api.php: line 86)

1064
You have an error in your SQL syntax near 'image/gif', NOW(), '')' at line 4
INSERT INTO mantis_project_file_table (id, project_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content) VALUES (null, 3, 'GIF Images', 'This is a sample GIF Image', '.\attach\doc-003-gificon.gif', 'doc-003-gificon.gif', '.\attach\', 142, 'image/gif', NOW(), '')

jfitzell

jfitzell

2003-02-24 09:53

reporter   ~0003799

I can't reproduce this at all.

It works fine in PHP 4.3.0 and 4.2.2. Uploading from IE6 on windows. Server is in apache on linux.

jfitzell

jfitzell

2003-02-24 10:07

reporter   ~0003801

and slashes should only be getting stripped if magic_quotes_gpc is turned on (in which case it needs to be stripped)... do you have magic quotes on or off? Presumably I don't see the problem because I'm on linux so I don't get \ in my paths.

Note that I tested both project upload and bug upload.

vboctor

vboctor

2003-02-24 21:59

manager   ~0003805

So this seems to be a Windows specific problem. I will do further testing and post the results here.

From my php.ini:
magic_quotes_gpc = On

vboctor

vboctor

2003-02-25 15:03

manager   ~0003817

This is now fixed in CVS. It will be included in 0.18.0a3.

The bug only applied to installations on Windows servers, hence I did the fix/testing in such environment, I would appreciate testing on other platforms.

andrew

andrew

2003-03-11 03:16

reporter   ~0003957

Last edited: 2003-03-11 03:19

I have this problem on 0.18.0a3 - Setting magic_quotes_gpc = Off seems to fix it.

edited on: 03-11-03 03:19

robbix

robbix

2003-04-05 14:16

reporter   ~0004135

Bug is still present in 0.18.0a4!:

The problem is that the $_FILES['file']['tmp_name'] value is not affected by magic quotes even if they are set to ON. It is set by Php after the file was transfered and MUST NOT be changed. It seems to be some kind of id for the temp-file because the slightest change makes the is_uploaded_file function fail.

I fixed it in my case adding the line:
$f_file['tmp_name'] = $_FILES['file']['tmp_name'];
directly after the line:
$f_file = gpc_get_file( 'file' );
in bug_file_add.php .

vboctor

vboctor

2003-04-06 05:19

manager   ~0004136

Fixed in CVS. Will be included in 0.18.0a5. Sorry for the delay, I had the fix for sometime but forgot to commit it.

The fix is to remove the call for gpc_strip_slahes() from within gpc_get_file().

Related Changesets

MantisBT: master 5022052e

2003-02-25 09:02

vboctor


Details Diff
Fix 0002992: Unable to attach files to bugs
This bug also applied to attaching documents to projects. The bug only occurs on Windows server. The reason
is that Windows uses \ where unix uses /. Since \ needs escaping and / don't, the problem only occured under
Windows.

I did a bit of cleanup as well. However, more work can be done in this area, and more factoring of common
code between attaching files to bugs, and documents to projects can happen.

M core/file_api.php
- (file_list_attachments): Order by date_added, rather than no ordering.
- (file_add):
- use non-escaped filename in constructing the new filename.
- removed some unnecessary escaping, like escaping of temp filename which is never saved to the db.
- some of the fields were not escaped before being saved to the db.

M bug_file_add.php
- Added operational successful message before the proceed link.

M proj_doc_add.php
- Used gpc_get_file() instead of directly accessing $HTTP_POST_FILES.
- If document prefix is empty, do not add the dash following it.
- Added support for FTP storage.
- Escaping of variables.

M proj_doc_edit_page.php
- Added the file type icon to the edit form.
- Hyperlinked the icon / filename to the file.

M proj_doc_page.php
- Use normal date format rather than complete date format.
- Use manage_project_threshold to give access to editing documents (rather than MANAGER). This can have
separate config option in the future.
- Minor changes in the layout.

git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@2022 <a class="text" href="/?p=mantisbt.git;a=object;h=f5dc347c">f5dc347c</a>-c33d-0410-90a0-b07cc1902cb9
Affected Issues
0002992
mod - proj_doc_add.php Diff File
mod - doc/ChangeLog Diff File
mod - bug_file_add.php Diff File
mod - core/file_api.php Diff File
mod - proj_doc_edit_page.php Diff File
mod - proj_doc_page.php Diff File

MantisBT: master a740894b

2003-04-05 22:18

vboctor


Details Diff
Fix 0002992: Unable to attach files to bugs on Windows servers with magic quotes ON

M core/gpc_api.php
- (gpc_get_file): The gpc_strip_slashes() is no longer called.

git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@2142 <a class="text" href="/?p=mantisbt.git;a=object;h=f5dc347c">f5dc347c</a>-c33d-0410-90a0-b07cc1902cb9
Affected Issues
0002992
mod - doc/ChangeLog Diff File
mod - core/gpc_api.php Diff File