View Issue Details

IDProjectCategoryView StatusLast Update
0011151mantisbtapi soappublic2010-07-29 10:45
Reportermagnomp 
Assigned Torombert 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.1.8 
Target Version1.2.2Fixed in Version1.2.2 
Summary0011151: Can't upload attachment to issue via soap interface
Description

Attachments sent to issues through the soap interface are always empty. I mean: The attachment do appear on the issue page, but with size = 0.

My attachments are stored on database. I havent tried this with other methods.

Steps To Reproduce

Call mc_issue_attachment_add to upload any file to an existing issue.

Additional Information

I noticed the mc_issue_attachment_add implementation calls base64_decode to decode the attachment data. I removed the call to base64_decode and now it works.
Im not an expert on PHP, neither on NuSoap, but I did some investigation on NuSoap code, and it looks like it already decodes all of the base64 parameters before calling the webservice implementation, so it must not be decoded again.

Heres my modified version of mc_issue_attachment_add:
function mc_issue_attachment_add( $p_username, $p_password, $p_issue_id, $p_name, $p_file_type, $p_content ) {
$t_user_id = mci_check_login( $p_username, $p_password );
if ( $t_user_id === false ) {
return new soap_fault( Client, , Access Denied );
}
if ( !file_allow_bug_upload( $p_issue_id, $t_user_id ) ) {
return new soap_fault( Client, , Access Denied );
}
if ( !access_has_bug_level( config_get( upload_bug_file_threshold ), $p_issue_id, $t_user_id ) ) {
return new soap_fault( Client, , Access Denied );
}
return mci_file_add( $p_issue_id, $p_name, $p_content, $p_file_type, bug );
}

I also suggest to change the documentation regarding $p_content parameter, as it says its base64, when the function actually receivess binary data.

TagsNo tags attached.

Relationships

duplicate of 0010235 closedgiallu mc_issue_attachment_add corrupts attachments 

Activities

rombert

rombert

2009-11-10 15:09

developer   ~0023642

The client must sent base64 encoded content, as specified by the WSDL. It will then be decoded by NuSOAP.

magnomp

magnomp

2009-11-10 16:11

reporter   ~0023644

Are you sure its a duplicate of 0010235? The issue page says it has been fixed in 1.1.7, but Ive experienced it on 1.1.8

rombert

rombert

2009-11-10 16:25

developer   ~0023645

I am sure since as a developer of the Mylyn-Mantis connector, which uses the SOAP API, have tested ( and have workarounds ) for both 1.1.6 ( pre-fix ) and 1.1.7 ( post-fix ).

magnomp

magnomp

2009-11-10 16:47

reporter   ~0023647

Have you tested with 1.1.8? Perhaps the bug has been reintroduced, or maybe its a new bug which happens to have the same symptoms. But Im sure this feature isnt working on 1.1.8.

The data is already being sent base64 encoded, Ive intercepted the soap request to check it.

The problem here is that the decoding is hapenning twice: First inside NuSOAP, and then inside mc_issue_attachment_add implementation.

As the seccond base64_decode call receives raw binary data, it returns nothing.

rombert

rombert

2009-11-10 17:25

developer   ~0023648

Ill take a closer look then.

hallids

hallids

2010-03-28 23:08

reporter   ~0024916

Last edited: 2010-03-28 23:21

View 3 revisions

I have encountered the same issue in Mantis version 1.2.0. It seems like this issue is a duplicate of 0010235 yet it still exists in 1.2.0.

As magnomp said, the fix was to remove the call to base64_decode() in the mc_issue_attachment_add() function.

rombert

rombert

2010-04-05 15:48

developer   ~0025037

I was able to reproduce this using the SOAP UI. I am not sure why both the PHP tests and the Eclipse integration worked, but this is a bug and I will fix it.

rombert

rombert

2010-04-28 14:43

developer   ~0025333

Ive committed a fix in the soap-attachments branch ( commit at http://git.mantisbt.org/?p=mantisbt.git;a=commit;h=b836b267cfc77aa516968fe05d1804743df133d7 ). Please verify that it does solve the problem youve reported.

Related Changesets

MantisBT: master dd284661

2010-04-28 18:25:42

rombert

Details Diff
Only decode attachments once when using the SOAP API

Attachments uploaded using the SOAP API calls are decoded by NuSOAP. Up till
now, we are also decoding the attachments, which caused the attached files
to be unreadable.

Although workarounds do exist, the correct way is to let NuSOAP apply the
Base64-decoding. The requirement for the users of the SOAP API is to
Base64-encode the attachments passed to mc_issue_attachment_add
mc_project_attachment_add and to Base64-decode the attachments retrieved
with mc_issue_attachment_get and mc_project_attachment_get.

Fixes 0011151: Can't upload attachment to issue via soap interface
mod - api/soap/mc_issue_attachment_api.php Diff File
mod - api/soap/mc_project_attachment_api.php Diff File
mod - tests/soap/AttachmentTest.php Diff File

MantisBT: master-1.2.x d04d8ea5

2010-04-28 18:25:42

rombert

Details Diff
Only decode attachments once when using the SOAP API

Attachments uploaded using the SOAP API calls are decoded by NuSOAP. Up till
now, we are also decoding the attachments, which caused the attached files
to be unreadable.

Although workarounds do exist, the correct way is to let NuSOAP apply the
Base64-decoding. The requirement for the users of the SOAP API is to
Base64-encode the attachments passed to mc_issue_attachment_add
mc_project_attachment_add and to Base64-decode the attachments retrieved
with mc_issue_attachment_get and mc_project_attachment_get.

Fixes 0011151: Can't upload attachment to issue via soap interface
mod - api/soap/mc_issue_attachment_api.php Diff File
mod - api/soap/mc_project_attachment_api.php Diff File
mod - tests/soap/AttachmentTest.php Diff File

Issue History

Date Modified Username Field Change
2009-11-10 10:34 magnomp New Issue
2009-11-10 15:09 rombert Note Added: 0023642
2009-11-10 15:09 rombert Relationship added duplicate of 0010235
2009-11-10 15:09 rombert Status new => resolved
2009-11-10 15:09 rombert Resolution open => duplicate
2009-11-10 15:09 rombert Assigned To => rombert
2009-11-10 16:11 magnomp Note Added: 0023644
2009-11-10 16:25 rombert Note Added: 0023645
2009-11-10 16:47 magnomp Note Added: 0023647
2009-11-10 17:25 rombert Note Added: 0023648
2009-11-10 17:25 rombert Status resolved => assigned
2010-03-28 23:08 hallids Note Added: 0024916
2010-03-28 23:19 hallids Note Edited: 0024916 View Revisions
2010-03-28 23:21 hallids Note Edited: 0024916 View Revisions
2010-04-05 15:48 rombert Note Added: 0025037
2010-04-05 15:48 rombert OS Linux =>
2010-04-05 15:48 rombert Platform PHP 5.2.9 =>
2010-04-05 15:48 rombert Target Version => 1.2.2
2010-04-05 15:48 rombert Sponsorship Total 0 =>
2010-04-05 15:48 rombert Description Updated View Revisions
2010-04-05 15:48 rombert Additional Information Updated View Revisions
2010-04-21 09:14 jreese Target Version 1.2.1 => 1.2.2
2010-04-28 14:43 rombert Note Added: 0025333
2010-04-28 15:00 rombert Status assigned => feedback
2010-05-12 16:18 rombert Changeset attached => MantisBT master dd284661
2010-05-12 16:18 rombert Changeset attached => MantisBT master-1.2.x d04d8ea5
2010-05-12 16:18 rombert Resolution duplicate => fixed
2010-05-12 16:18 rombert Fixed in Version => 1.2.2
2010-05-12 16:19 rombert Status feedback => resolved
2010-07-29 10:45 jreese Status resolved => closed