diff --git a/core/includes/token.inc b/core/includes/token.inc index 5c74519..b4e409e 100644 --- a/core/includes/token.inc +++ b/core/includes/token.inc @@ -113,13 +113,13 @@ function token_replace($text, array $data = array(), array $options = array()) { */ function token_scan($text) { // Matches tokens with the following pattern: [$type:$name] - // $type and $name may not contain [ ] or whitespace characters. - // $type may not contain : characters, but $name may. + // $type and $name may not contain [ ] characters. + // $type may not contain : or whitespace characters, but $name may. preg_match_all('/ \[ # [ - pattern start ([^\s\[\]:]*) # match $type not containing whitespace : [ or ] : # : - separator - ([^\s\[\]]*) # match $name not containing whitespace [ or ] + ([^\[\]]*) # match $name not containing [ or ] \] # ] - pattern end /x', $text, $matches); diff --git a/only-tests.patch b/only-tests.patch new file mode 100644 index 0000000..0b600af --- /dev/null +++ b/only-tests.patch @@ -0,0 +1,51 @@ +diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenScanTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenScanTest.php +new file mode 100644 +index 0000000..c843384 +--- /dev/null ++++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenScanTest.php +@@ -0,0 +1,42 @@ ++ 'Token scanning', ++ 'description' => 'Scan token-like patterns in a dummy text to check token scanning.', ++ 'group' => 'System', ++ ); ++ } ++ ++ /** ++ * Scans dummy text, then tests the output. ++ */ ++ function testTokenScan() { ++ // Define text with valid and not valid, fake and existing token like ++ // strings. ++ $text = 'First a [valid:simple], but dummy token, and a dummy [valid:token with: spaces].'; ++ $text .= 'Then a [not valid:token].'; ++ $text .= 'Last an existing token: [node:author:name].'; ++ $token_wannabes = token_scan($text); ++ ++ $this->assertTrue(isset($token_wannabes['valid']['simple']), 'Simple valid token matched.'); ++ $this->assertTrue(isset($token_wannabes['valid']['token with: spaces']), 'Valid token with space characters in the token name matched.'); ++ $this->assertFalse(isset($token_wannabes['not valid']), 'Not valid token with spaces in the token type not matched.'); ++ $this->assertTrue(isset($token_wannabes['node']), 'Existing valid token matched.'); ++ } ++ ++} +diff --git a/test.patch b/test.patch +new file mode 100644 +index 0000000..e69de29