diff options
author | Dries Buytaert <dries@buytaert.net> | 2011-04-23 20:09:54 -0400 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2011-04-23 20:09:54 -0400 |
commit | d379f3d7bdfe4ef9c0f0fe629394048229d6c2e2 (patch) | |
tree | 851846fad7e3cd46f28f11827c6b9f13c9870d0c /includes | |
parent | 7418dedf51659f3d1840486477b74755928bc89a (diff) | |
download | brdo-d379f3d7bdfe4ef9c0f0fe629394048229d6c2e2.tar.gz brdo-d379f3d7bdfe4ef9c0f0fe629394048229d6c2e2.tar.bz2 |
- Patch #733192 by pillarsdotnet, Sutharsan, Letharion, clemens.tolboom: tokens enclosed in [ ] are not recognized.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/token.inc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/includes/token.inc b/includes/token.inc index c31f9e6c3..63481f788 100644 --- a/includes/token.inc +++ b/includes/token.inc @@ -17,7 +17,7 @@ * * Tokens follow the form: [$type:$name], where $type is a general class of * tokens like 'node', 'user', or 'comment' and $name is the name of a given - * placeholder. For example, [node:title]. + * placeholder. For example, [node:title] or [node:created:since]. * * In addition to raw text containing placeholders, modules may pass in an array * of objects to be used when performing the replacement. The objects should be @@ -103,9 +103,16 @@ function token_replace($text, array $data = array(), array $options = array()) { * An associative array of discovered tokens, grouped by type. */ function token_scan($text) { - // Matches tokens with the following pattern: [$type:$token] - // $type and $token may not contain white spaces. - preg_match_all('/\[([^\s\]:]*):([^\s\]]*)\]/', $text, $matches); + // 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. + preg_match_all('/ + \[ # [ - pattern start + ([^\s\[\]:]*) # match $type not containing whitespace : [ or ] + : # : - separator + ([^\s\[\]]*) # match $name not containing whitespace [ or ] + \] # ] - pattern end + /x', $text, $matches); $types = $matches[1]; $tokens = $matches[2]; |