Commit a81031d4 authored by catch's avatar catch
Browse files

Issue #3533698 by nod_, longwave, danflanagan8, hammerslammer, wim leers:...

Issue #3533698 by nod_, longwave, danflanagan8, hammerslammer, wim leers: BigPipe does not handle multiple </body> tags correctly

(cherry picked from commit 1124c4f9)
parent 52758cae
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ public function sendContent(BigPipeResponse $response) {
    // that strings in inline JavaScript or CDATA sections aren't used instead.
    $parts = explode('</body>', $content);
    $post_body = array_pop($parts);
    $pre_body = implode('', $parts);
    $pre_body = implode('</body>', $parts);

    $this->sendPreBody($pre_body, $nojs_placeholders, $cumulative_assets);
    $this->sendPlaceholders($placeholders, $this->getPlaceholderOrder($pre_body, $placeholders), $cumulative_assets);
+5 −2
Original line number Diff line number Diff line
@@ -54,10 +54,10 @@ public function testMultipleClosingBodies_2678662(): void {
    $this->drupalGet(Url::fromRoute('big_pipe_regression_test.2678662'));

    // Confirm that AJAX behaviors were instantiated, if not, this points to a
    // JavaScript syntax error.
    // JavaScript syntax error and the JS variable has the appropriate content.
    $javascript = <<<JS
    (function(){
      return Object.keys(Drupal.ajax.instances).length > 0;
      return Object.keys(Drupal.ajax.instances).length > 0 && hitsTheFloor === "</body>";
    }())
JS;
    $this->assertJsCondition($javascript);
@@ -73,6 +73,9 @@ public function testMultipleClosingBodies_2678662(): void {
    // in an inline script.
    $this->assertSession()
      ->responseNotContains($js_code_until_closing_body_tag . "\n" . BigPipe::START_SIGNAL);
    // But the inline script itself should not be altered.
    $this->assertSession()
      ->responseContains(BigPipeRegressionTestController::MARKER_2678662);
  }

  /**