Skip to content

Commit

Permalink
Don’t replace <html> tag if it is e.g. <html lang=“en”>
Browse files Browse the repository at this point in the history
  • Loading branch information
n7studios committed Sep 25, 2024
1 parent 4ed8a5e commit 0635ccf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/class-convertkit-api-v4.php
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ public function get_html( $url, $body_only = true ) {

// If the HTML is missing the <html> tag, it's likely to be a legacy form.
// Wrap it in <html>, <head> and <body> tags now, so we can inject the UTF-8 Content-Type meta tag.
if ( strpos( $body, '<html>' ) === false ) {
if ( strpos( $body, '<html' ) === false ) {
$body = '<html><head></head><body>' . $body . '</body></html>';
}

Expand Down
13 changes: 13 additions & 0 deletions tests/wpunit/APITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6177,6 +6177,11 @@ public function testGetLandingPageHTML()

// Check that rocket-loader.min.js has been removed, as including it breaks landing page redirects.
$this->assertStringNotContainsString('rocket-loader.min.js', $result);

// Check that the <html> tag wasn't replaced, as this isn't a legacy landing page.
// It should be preserved as e.g. <html lang="en">.
$this->assertStringContainsString('<html lang="en">');
$this->assertStringNotContainsString('<html>');
}

/**
Expand All @@ -6196,6 +6201,11 @@ public function testGetLandingPageWithCharacterEncodingHTML()

// Check that rocket-loader.min.js has been removed, as including it breaks landing page redirects.
$this->assertStringNotContainsString('rocket-loader.min.js', $result);

// Check that the <html> tag wasn't replaced, as this isn't a legacy landing page.
// It should be preserved as e.g. <html lang="en">.
$this->assertStringContainsString('<html lang="en">');
$this->assertStringNotContainsString('<html>');
}

/**
Expand All @@ -6212,6 +6222,9 @@ public function testGetLegacyLandingPageHTML()

// Check that rocket-loader.min.js has been removed, as including it breaks landing page redirects.
$this->assertStringNotContainsString('rocket-loader.min.js', $result);

// Check that the <html> tag was added, as this isn't included in legacy landing pages.
$this->assertStringContainsString('<html>');
}

/**
Expand Down

0 comments on commit 0635ccf

Please sign in to comment.