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

Bug #16637 Does not handle Carriage Return (\r)
Submitted: 2009-09-24 03:00 UTC
From: auxone Assigned: till
Status: Closed Package: File_IMC (version 0.4.0)
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: 0.4.1    
Subscription  


 [2009-09-24 03:00 UTC] auxone (Tyler Thackray)
Description: ------------ Parse::unescape() and Build:escape() do not handle \r as they do \n. In practice, I've found that often a \r will find it's way into the input used to build a card. When the card is later parsed, the segment after the \r is lost. Because of the way the class is designed, it is easy to escape() the \r, however it required a very slight change in the unescape() method to get the \r back. In light of this, I just added the \r to escape() and unescape() and it is my recommendation that you do the same. Having said that, I am not expert on IMC standards so perhaps this would violate that, but what I do know is that in it's current state a \r breaks cards. Thanks.

Comments

 [2009-09-24 19:20 UTC] till (Till Klampaeckel)
-Status: Open +Status: Feedback -Assigned To: +Assigned To: till
Can you supply a patch to what you changed? Also, would you be able to upload an example or even a test? If a test is an issue, I'd be happy to build one
 [2009-09-24 19:34 UTC] auxone (Tyler Thackray)
I regret to inform you that I really don't have much time to develop a test or patch, but I can point you in the right direction. As far as a patch, the code change is very simple. 1. In Build.php in the escape() function, the regex should be $regex = '(?<!\\\\)([\:\;\,\\n\\r])'; 2. In Parse.php in the unescape() function, find and replace should be $find = array('\:', '\;', '\,', '\n', '\r'); $replace = array(':', ';', ',', "\n", "\r"); For a test, just create a vCard with some \r in it and you will see what I mean. If you want a real world example, most HTML form <textarea> will use \r\n for the line break.
 [2010-06-27 22:06 UTC] till (Till Klampaeckel)
-Status: Feedback +Status: Closed -Type: Feature/Change Request +Type: Bug -Roadmap Versions: +Roadmap Versions: 0.4.1
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. I'm making this a bug since I guess it should have supported these to begin with. ;-)
 [2010-06-27 22:07 UTC] till (Till Klampaeckel)
Btw, applied in r300776.