Warning and notice fixed
authorMichael <heluecht@pirati.ca>
Sat, 29 Dec 2018 09:53:31 +0000 (09:53 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 29 Dec 2018 09:53:31 +0000 (09:53 +0000)
src/Content/Text/HTML.php
src/Protocol/ActivityPub/Processor.php

index 276094a..adfc60e 100644 (file)
@@ -180,7 +180,9 @@ class HTML
                $xpath = new DomXPath($doc);
                $list = $xpath->query("//pre");
                foreach ($list as $node) {
-                       $node->nodeValue = str_replace("\n", "\r", $node->nodeValue);
+                       // Ensure to escape unescaped & - they will otherwise raise a warning
+                       $safe_value = preg_replace('/&(?!\w+;)/', '&amp;', $node->nodeValue);
+                       $node->nodeValue = str_replace("\n", "\r", $safe_value);
                }
 
                $message = $doc->saveHTML();
index d2f5b3b..1a63149 100644 (file)
@@ -329,6 +329,11 @@ class Processor
                        return;
                }
 
+               if (empty($object['id'])) {
+                       Logger::log('Activity ' . $url . ' has got not id, aborting. ' . json_encode($object));
+                       return;
+               }
+
                $activity = [];
                $activity['@context'] = $object['@context'];
                unset($object['@context']);