Skip to content

Commit

Permalink
Fix issue with infinite loop on new applications.
Browse files Browse the repository at this point in the history
  • Loading branch information
dshanske committed Aug 25, 2024
1 parent 38d77de commit fe7bd68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 4 additions & 10 deletions includes/class-indieauth-client-discovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
6 changes: 5 additions & 1 deletion includes/class-indieauth-client-taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit fe7bd68

Please sign in to comment.