Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.6.3

Bug #15559 Inserting new message to a Mbox is not guaranteed to produce a valid Mbox
Submitted: 2009-01-08 13:49 UTC
From: cfturkja Assigned: cweiske
Status: Closed Package: Mail_Mbox (version 0.5.1)
PHP Version: 5.1.6 OS: Linux
Roadmaps: (Not assigned)    
Comments Add Comment Add patch

Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem : 47 + 30 = ?

 [2009-01-08 13:49 UTC] cfturkja (Jari Turkia)
Description: ------------ Background: Mbox is a flat-file format for storing multiple messages. Messages are separated by a suitable mechanism matching regexp similar to this: ^From\s+ Test script: --------------- require_once("Mail/Mbox.php"); $mbox = new Mail_Mbox("my.mbox"); $mbox->open(); $mbox->insert("something completely illegal", null); $mbox->insert("you cannot touch this", null); $mbox->close(); Expected result: ---------------- Silent run of the script producing a valid Unix Mbox, something like: -----begin-mbox----- From something completely illegal From you cannot touch this -----end-mbox----- The warning PHP Warning: filemtime(): stat failed for my.mbox in /usr/share/pear/Mail/Mbox.php on line 657 should absolutely be suppressed Actual result: -------------- A warning: PHP Warning: filemtime(): stat failed for my.mbox in /usr/share/pear/Mail/Mbox.php on line 657 and crappy Mbox which cannot be read back using any other library or utility, containing: -----begin-mbox----- something completely illegal you cannot touch this -----end-mbox----- And don't complain my example and code as being naive and too simplistic. I'm just being terse here. Just image my message as being a fully valid SMTP-message. The results will be same.


 [2009-01-15 14:48 UTC] doconnor (Daniel O'Connor)
That's really odd - filemtime() can't stat? Can you work out why (permissions? ownership of the file?) Supressing this doesn't seem like the right idea; as this is a filesystemish error; and we do want to know about it - but a call to is_readable() or similar before might not hurt
 [2009-01-15 15:09 UTC] cfturkja (Jari Turkia)
Well. How about file_exists() before stat? This is insert, nobody guarantees an existing Mbox.
 [2009-01-16 11:58 UTC] cweiske (Christian Weiske)
Am I seeing this right, that you described two problems here? One for a non-existing file, and one for inputting invalid messages?
 [2009-01-16 12:03 UTC] cfturkja (Jari Turkia)
Yes. There are two separate problems. One for a warning (which can be ignored, but is a nuisance) and one for a functional error which makes this entire package unusable. At minimum this package should be able to read its own output.
 [2009-08-01 15:04 UTC] cweiske (Christian Weiske)
Plan to fix the invalidity problem: New method to check if message is valid - that is, begins with "From ". If not, raise pear error. That method needs to be called when adding and when updating.
 [2009-08-02 17:32 UTC] cweiske (Christian Weiske)
-Status: Feedback +Status: Verified
I fixed the invalid message problem in the just released version 0.5.2. The insert thingy is still open. I'll transfer this into another bug, because two issues in one bug is bad.
 [2009-08-02 17:44 UTC] cweiske (Christian Weiske)
Followup-bug in bug #16487. This issue with invalid mails is fixed in 0.5.2 - I check for "From " now. If you have more rules that should be followed, just cry out and re-open the bug.
 [2009-08-02 17:44 UTC] cweiske (Christian Weiske)
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cweiske