Revision: 2256
          http://mrbs.svn.sourceforge.net/mrbs/?rev=2256&view=rev
Author:   cimorrison
Date:     2012-01-27 10:00:08 +0000 (Fri, 27 Jan 2012)
Log Message:
-----------
- Fixed bug so that valid files ending in CRLF are accepted
- Improved handling of badly formed .ics files

Modified Paths:
--------------
    mrbs/branches/ics_import/web/import.php

Modified: mrbs/branches/ics_import/web/import.php
===================================================================
--- mrbs/branches/ics_import/web/import.php     2012-01-26 17:37:04 UTC (rev 
2255)
+++ mrbs/branches/ics_import/web/import.php     2012-01-27 10:00:08 UTC (rev 
2256)
@@ -359,10 +359,22 @@
     $vcalendar = file_get_contents($_FILES['ics_file']['tmp_name']);
     if ($vcalendar !== FALSE)
     {
+      $vevents = array();
       $lines = explode("\r\n", ical_unfold($vcalendar));
+      $first_line = array_shift($lines);
+      if (isset($first_line))
+      {
+        // Get rid of empty lines at the end of the file
+        do
+        {
+          $last_line = array_pop($lines);
+        }
+        while (isset($last_line) && ($last_line == ''));
+      }
       // Check that this bears some resemblance to a VCALENDAR
-      if ((array_shift($lines) != "BEGIN:VCALENDAR") ||
-          (array_pop($lines) != "END:VCALENDAR"))
+      if (!isset($last_line) ||
+          ($first_line != "BEGIN:VCALENDAR") ||
+          ($last_line != "END:VCALENDAR"))
       {
         echo "<p>\n" . get_vocab("badly_formed_ics") . "</p>\n";
       }
@@ -372,7 +384,6 @@
       // a VEVENT but we will use the PHP definition of the timezone)
       else
       {
-        $vevents = array();
         while ($line = array_shift($lines))
         {
           if ($line == "BEGIN:VEVENT")

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to