Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-11148

Fix uploading attachments from Android 4 powered devices

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.0.11
    • 3.1.0-RC3
    • Posting
    • None

    Description

      Trying to upload an attachment to phpBB from some mobile devices running Android 4.x results in the following error:

      The image file you tried to attach is invalid.

      This is caused by an invalid mimetype, returned by the default Android browser. The incorrect mimetype is: application/octet-stream
      phpBB looks if it contains image/ and is therefore failing the check and rejecting the attachment.

      I've come to this conclusion by upload tests from people on different mobile devices, operating systems and browsers:

      [OK]   HTC Desire Android 2.3.5
      [OK]   HTC Sensation Android 2.3.4
      [FAIL] HTC Sensation Android 4.0.3
      [FAIL] HTC One S Android 4
      [OK]   HTC One S Android 4 (Firefox)
      [FAIL] HTC HD2 Android 4.1.2
      [FAIL] HTC EVO 4G LTE Android 4.0.4 
      [FAIL] Nexus S Android 4
      [OK]   Samsung Galaxy S2 Android 4.0.4 
      [OK]   Samsung Galaxy S2 Android 4.0.4 (Opera Mobile)
      [OK]   Samsung Galaxy S3 Android 4.0.4
      [OK]   Samsung Galaxy S3 Android 4.0.4 (Firefox) 
      [OK]   iPhone 4 iOS 6.0
      [OK]   iPad 2 iOS 6.0 (10A403)
      [OK]   Samsung Focus (SGH-i917) Windows Phone 7.5 
      

      (Thanks for testing everyone)

      Please note that disabling the ACP setting "Check attachment files, Some browsers can be tricked to assume an incorrect mimetype for uploaded files.." will not help because it's checked in includes/functions_posting.php, regardless of the setting. (the setting is only working in includes/functions_upload.php which is runned after functions_posting)

      includes/functions_posting.php

      // Make sure the image category only holds valid images...
      if ($cat_id == ATTACHMENT_CATEGORY_IMAGE && !$file->is_image())
      {
      	$file->remove();
       
      	// If this error occurs a user tried to exploit an IE Bug by renaming extensions
      	// Since the image category is displaying content inline we need to catch this.
      	trigger_error($user->lang['ATTACHED_IMAGE_NOT_IMAGE']);
      }
      

      includes/functions_upload.php

      /**
      * Check if file is an image (mimetype)
      *
      * @return true if it is an image, false if not
      */
      function is_image()
      {
      	return (strpos($this->mimetype, 'image/') !== false) ? true : false;
      }
      

      Attachments

        Issue Links

          Activity

            People

              Marc Marc
              Derky Derky
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: