summaryrefslogtreecommitdiffstatshomepage
path: root/core
diff options
context:
space:
mode:
authorAlex Pott <alex.a.pott@googlemail.com>2025-04-16 13:23:42 +0200
committerAlex Pott <alex.a.pott@googlemail.com>2025-04-16 14:56:40 +0200
commit4fd6234027ca5778932266852376afbc8cea2b4c (patch)
tree01009c804cf33000873489f656aa29998e2205fd /core
parenta551f2b2feac369df92ef7f8888c7fef309a8700 (diff)
downloaddrupal-4fd6234027ca5778932266852376afbc8cea2b4c.tar.gz
drupal-4fd6234027ca5778932266852376afbc8cea2b4c.zip
Issue #3513307 by bigbabert, smustgrave, nicxvan, quietone, ghost of drupal past: Use xpath instead of preg_match to search html string in BrowserTestBase
Diffstat (limited to 'core')
-rw-r--r--core/tests/Drupal/Tests/BrowserTestBase.php5
1 files changed, 2 insertions, 3 deletions
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index 457e22286f4..12228dbea72 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -609,9 +609,8 @@ abstract class BrowserTestBase extends TestCase {
* The JSON decoded drupalSettings value from the current page.
*/
protected function getDrupalSettings() {
- $html = $this->getSession()->getPage()->getContent();
- if (preg_match('@<script type="application/json" data-drupal-selector="drupal-settings-json">([^<]*)</script>@', $html, $matches)) {
- $settings = Json::decode($matches[1]);
+ if ($elements = $this->xpath('//script[@type="application/json" and @data-drupal-selector="drupal-settings-json"]')) {
+ $settings = Json::decode($elements[0]->getText());
if (isset($settings['ajaxPageState']['libraries'])) {
$settings['ajaxPageState']['libraries'] = UrlHelper::uncompressQueryParameter($settings['ajaxPageState']['libraries']);
}