Commit 551868bb authored by Dries's avatar Dries
Browse files

Issue #1816556 by valthebald: drupalSetContent() incorrectly defines boundaries of Drupal.settings.

parent f101830d
......@@ -2049,7 +2049,7 @@ protected function drupalSetContent($content, $url = 'internal:') {
$this->plainTextContent = FALSE;
$this->elements = FALSE;
$this->drupalSettings = array();
if (preg_match('/var drupalSettings = (.*?);/', $content, $matches)) {
if (preg_match('/var drupalSettings = (.*?);$/m', $content, $matches)) {
$this->drupalSettings = drupal_json_decode($matches[1]);
}
}
......
......@@ -51,6 +51,10 @@ function testDrupalHTTPRequest() {
$this->drupalSetContent($result->data);
$this->assertTitle(t('Test page | @site-name', array('@site-name' => config('system.site')->get('name'))));
// Test that Drupal.settings is properly parsed.
$settings = $this->drupalGetSettings();
$this->assertIdentical($settings['test-setting'], 'azAZ09();.,\\\/-_{}');
// Test that code and status message is returned.
$result = drupal_http_request(url('pagedoesnotexist', array('absolute' => TRUE)));
$this->assertTrue(!empty($result->protocol), 'Result protocol is returned.');
......
......@@ -20,6 +20,7 @@ function test_page_test_menu() {
* @see test_page_test_menu()
*/
function test_page_test_page() {
drupal_add_js(array('test-setting' => 'azAZ09();.,\\\/-_{}'), array('type' => 'setting'));
drupal_set_title(t('Test page'));
return t('Test page text.');
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment