]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Bookmark/deliciousbackupimporter.php
More info for a proper, fancy-url lighttpd setup
[quix0rs-gnu-social.git] / plugins / Bookmark / deliciousbackupimporter.php
index 1eb015f380efa63a6f2a313c867439cd9cb2f51b..0ceba61d89a1619b009cf771bf4e20b82b335a1a 100644 (file)
@@ -74,13 +74,26 @@ class DeliciousBackupImporter extends QueueHandler
     {
         list($user, $body) = $data;
 
-        $doc = $this->importHTML($body);
+        try {
+            $doc = $this->importHTML($body);
+        } catch (ClientException $cex) {
+            // XXX: message to the user
+            common_log(LOG_WARNING, $cex->getMessage());
+            return true;
+        }
+
+        // If we can't parse it, it's no good
+
+        if (empty($doc)) {
+            return true;
+        }
 
         $dls = $doc->getElementsByTagName('dl');
 
         if ($dls->length != 1) {
-            // TRANS: Client exception thrown when a file upload is incorrect.
-            throw new ClientException(_m('Bad import file.'));
+            // XXX: message to the user
+            common_log(LOG_WARNING, 'Bad input file');
+            return true;
         }
 
         $dl = $dls->item(0);
@@ -110,9 +123,11 @@ class DeliciousBackupImporter extends QueueHandler
                 case 'dd':
                     $dd = $child;
 
-                    // This <dd> contains a description for the bookmark in
-                    // the preceding <dt> node.
-                    $saved = $this->importBookmark($user, $dt, $dd);
+                    if (!empty($dt)) {
+                        // This <dd> contains a description for the bookmark in
+                        // the preceding <dt> node.
+                        $saved = $this->importBookmark($user, $dt, $dd);
+                    }
 
                     $dt = null;
                     $dd = null;