summaryrefslogtreecommitdiff
path: root/plugins/OStatus
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-03-18 17:55:21 -0700
committerBrion Vibber <brion@pobox.com>2010-03-18 17:55:21 -0700
commit08faff22784c8a004a858afa7372061c2bd3d8f3 (patch)
treea46375450a2e0c28b22c1334b20b8e165628dfa8 /plugins/OStatus
parent3e2e88b0dfb0f5b3baa336a9b3f69e8e8244c8e6 (diff)
Work around weird bug with HTML normalization via PHP DOM module; if source had xmlns and xml:lang I ended up with double output, breaking the subsequent parsing. Will have to track this down later and report upstream if not already resolved.
Diffstat (limited to 'plugins/OStatus')
-rw-r--r--plugins/OStatus/extlib/hkit/hkit.class.php2
-rw-r--r--plugins/OStatus/lib/discoveryhints.php21
2 files changed, 21 insertions, 2 deletions
diff --git a/plugins/OStatus/extlib/hkit/hkit.class.php b/plugins/OStatus/extlib/hkit/hkit.class.php
index c3a54cff6..fec6f4d8f 100644
--- a/plugins/OStatus/extlib/hkit/hkit.class.php
+++ b/plugins/OStatus/extlib/hkit/hkit.class.php
@@ -472,4 +472,4 @@
}
-?> \ No newline at end of file
+?>
diff --git a/plugins/OStatus/lib/discoveryhints.php b/plugins/OStatus/lib/discoveryhints.php
index 4da2ec0f1..0273b5a92 100644
--- a/plugins/OStatus/lib/discoveryhints.php
+++ b/plugins/OStatus/lib/discoveryhints.php
@@ -174,6 +174,26 @@ class DiscoveryHints {
error_reporting($old);
if ($ok) {
+ // If the original had xmlns or xml:lang attributes on the
+ // <html>, we seen to end up with duplicates, which causes
+ // parse errors. Remove em!
+ //
+ // For some reason we have to iterate and remove them twice,
+ // *plus* they don't show up on hasAttribute() or removeAttribute().
+ // This might be some weird bug in PHP or libxml2, uncertain if
+ // it affects other folks consistently.
+ $root = $dom->documentElement;
+ foreach ($root->attributes as $i => $x) {
+ if ($i == 'xmlns' || $i == 'xml:lang') {
+ $root->removeAttributeNode($x);
+ }
+ }
+ foreach ($root->attributes as $i => $x) {
+ if ($i == 'xmlns' || $i == 'xml:lang') {
+ $root->removeAttributeNode($x);
+ }
+ }
+
// hKit doesn't give us a chance to pass the source URL for
// resolving relative links, such as the avatar photo on a
// Google profile. We'll slip it into a <base> tag if there's
@@ -192,7 +212,6 @@ class DiscoveryHints {
$head = $heads->item(0);
} else {
$head = $dom->createElement('head');
- $root = $dom->documentRoot;
if ($root->firstChild) {
$root->insertBefore($head, $root->firstChild);
} else {