From fe7bd680e2b03b3ef2de61cb6c57b78cef06bb09 Mon Sep 17 00:00:00 2001 From: David Shanske Date: Sun, 25 Aug 2024 17:36:15 +0000 Subject: [PATCH] Fix issue with infinite loop on new applications. --- includes/class-indieauth-client-discovery.php | 14 ++++---------- includes/class-indieauth-client-taxonomy.php | 6 +++++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/includes/class-indieauth-client-discovery.php b/includes/class-indieauth-client-discovery.php index 43568e3..8f29c23 100644 --- a/includes/class-indieauth-client-discovery.php +++ b/includes/class-indieauth-client-discovery.php @@ -32,8 +32,9 @@ public function __construct( $client_id ) { if ( 'localhost' === wp_parse_url( $client_id, PHP_URL_HOST ) ) { return; } - + error_log( 'Pre-Parse' ); $response = self::parse( $client_id ); + error_log( 'Post-Parse' ); if ( is_wp_error( $response ) ) { error_log( __( 'Failed to Retrieve IndieAuth Client Details ', 'indieauth' ) . wp_json_encode( $response ) ); // phpcs:ignore return; @@ -113,15 +114,8 @@ private function parse( $url ) { $this->client_uri = $this->json['client_uri']; } } elseif ( 'text/html' === $content_type ) { - $content = wp_remote_retrieve_body( $response ); - $domdocument = new DOMDocument(); - libxml_use_internal_errors( true ); - if ( function_exists( 'mb_convert_encoding' ) ) { - $content = mb_convert_encoding( $content, 'HTML-ENTITIES', mb_detect_encoding( $content ) ); - } - $domdocument->loadHTML( $content ); - libxml_use_internal_errors( false ); - $this->get_mf2( $domdocument, $url ); + $content = wp_remote_retrieve_body( $response ); + $this->get_mf2( $content, $url ); if ( ! empty( $this->mf2 ) ) { if ( array_key_exists( 'name', $this->mf2 ) ) { $this->client_name = $this->mf2['name'][0]; diff --git a/includes/class-indieauth-client-taxonomy.php b/includes/class-indieauth-client-taxonomy.php index affe29e..4c5d9ed 100755 --- a/includes/class-indieauth-client-taxonomy.php +++ b/includes/class-indieauth-client-taxonomy.php @@ -143,7 +143,11 @@ public static function add_client( $url, $name = null, $icon = null ) { 'client_id' => $url, ); } - return self::add_client( $url, $client->get_name(), $client->get_icon() ); + $name = $client->get_name(); + $icon = $client->get_icon(); + if ( empty( $name ) ) { + $name = self::generate_slug( $url ); + } } $icon = self::sideload_icon( $icon, $url );