On 6/7/08, Runar Olsen <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
>> I'm working on a script to look for a UUEncoded attachment in an NNTP
>> message. I'm running into problems with spaces in the filename of the
>> attachment.
>> UUEncoded files in the body of a message will start with the word "begin",
>> then the size of the file, then the name of the file. Then the encoded
>> file, finaly then a newline with only the word "end" like so:
>>
>> begin 644 photo.jpg
>> -encoded image-
>> end
>>
>> The script looks for that first line in that order so as not to confuse it
>> with the word "begin" showing up somewhere else in the message. Here is
>> the particular line of code that searches for that:
>>
>> if (preg_match("/^begin\s+[0-9][0-9][0-9]\s+(.+?)\s*\r?\n/m", $body))
>>
>>
> The part where you fetch the file name (.+?)\s* is what is causing the
> problem as when the file name is "a something.jpg" then (.+?) matches a then
> \s matches the space and the rest is skipped.
>
>>
>> The problem I'm running into is with spaces in the file name. For example,
>> if it starts with this:
>>
>> begin 644 a_nice_photo.jpg
>>
>>
>> it works just fine, decodes the image and places it below the text of the
>> message. But if the line looks like this:
>>
>> begin 644 a nice photo.jpg
>>
>> with spaces in the filename, the script seems to stop looking after the
>> "a", thinks this is just normal text in the message and doesn't decode the
>> image. This results in the raw UUEncoded text showing up where the image
>> should.
>>
>> I'm stumped. Any ideas?
>>
>> -Allen
>>
>>
>>
>> --
>>
>>
>
>
what about just writing a utility to manipulate the files names to remove
spaces?

-- 

Bastien

Cat, the other other white meat

Reply via email to