php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #7418 Mac WWW upload error FIX
Submitted: 2000-10-23 19:32 UTC Modified: 2001-10-28 17:32 UTC
From: adam at webglow dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.3pl1 OS: Any
Private report: No CVE-ID: None
 [2000-10-23 19:32 UTC] adam at webglow dot com
I found the following bit of code for removing the data fork from a file uploaded via www by a Mac so that the file uploaded is usable. Trouble is it's in PERL and I want to run it directly from PHP. So, my question is two fold:

1) Would it be possible for someone to translate it from PERL -> PHP

2) Would it be possible to add this code into PHP to solve the Mac upload problem once and for all?

Here's a copy of the code:
--------------------------
The following subroutine "extracts the data fork (what most people would call the real file contents) from the middle of the macbinary encapsulation (which also includes the resource fork and some metadata like type and creator). I got this code off the net, so if it's not entirely accurate, I'm sure one of you will tell me. Basically, the first 128 bytes appears to be a header, and bytes 84 through 87 appear to be a network-order integer value of how many bytes immediately following the header constitute the datafork. So, with the right manipulation, I'm done."

sub strip_fork_from_fh {
	my $fh = shift;
	   
	my $len = read $fh, (my $buf), 128; # read the header
	die "short read: $len" unless $len == 128;
	my $bytes = unpack("x83N", $buf); # get datafork length
	read $fh, $buf, $bytes;
	$buf;
}

You can view the article I found the code from at http://www.stonehenge.com/merlyn/WebTechniques/col46.html


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-28 17:32 UTC] sniper@php.net
This should be fixed in CVS now. You can try the latest 
CVS snapshot from http://snaps.php.net/

Also, there are some minor leaks still in the new code.
If you encounter such leaks, please send the shortest
possible code + html with which you can reproduce the leak
to php-dev@lists.php.net (or me) so we can get rid of these leaks. 

This fix will be in PHP 4.2.0.

--Jani

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 21:01:30 2025 UTC