MantisBT

View Issue Details Jump to Notes ] Wiki ] Related Changesets ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0011151mantisbtapi soappublic2009-11-10 10:342010-07-29 10:45
Reportermagnomp 
Assigned Torombert 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version1.1.8 
Target Version1.2.2Fixed in Version1.2.2 
Summary0011151: Can't upload attachment to issue via soap interface
DescriptionAttachments 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 haven't tried this with other methods.
Steps To ReproduceCall mc_issue_attachment_add to upload any file to an existing issue.
Additional InformationI 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.
I'm 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.

Here's 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 it's base64, when the function actually receivess binary data.
TagsNo tags attached.
Attached Files

- Relationships
duplicate of 0010235closedgiallu mc_issue_attachment_add corrupts attachments 

-  Notes
User avatar (0023642)
rombert (developer)
2009-11-10 15:09

The client must sent base64 encoded content, as specified by the WSDL. It will then be decoded by NuSOAP.
User avatar (0023644)
magnomp (reporter)
2009-11-10 16:11

Are you sure it's a duplicate of 0010235? The issue page says it has been fixed in 1.1.7, but I've experienced it on 1.1.8
User avatar (0023645)
rombert (developer)
2009-11-10 16:25

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 ).
User avatar (0023647)
magnomp (reporter)
2009-11-10 16:47

Have you tested with 1.1.8? Perhaps the bug has been reintroduced, or maybe it's a new bug which happens to have the same symptoms. But I'm sure this feature isn't working on 1.1.8.

The data is already being sent base64 encoded, I've 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.
User avatar (0023648)
rombert (developer)
2009-11-10 17:25

I'll take a closer look then.
User avatar (0024916)
hallids (reporter)
2010-03-28 23:08
edited on: 2010-03-28 23:21

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.

User avatar (0025037)
rombert (developer)
2010-04-05 15:48

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.
User avatar (0025333)
rombert (developer)
2010-04-28 14:43

I've 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 you've reported.

- Related Changesets
MantisBT: master dd284661
Timestamp: 2010-04-28 18:25:42
Author: 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
Timestamp: 2010-04-28 18:25:42
Author: 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


MantisBT 1.2.17 [^]
Copyright © 2000 - 2014 MantisBT Team
Time: 0.1329 seconds.
memory usage: 3,105 KB
Powered by Mantis Bugtracker