Index: trunk/extensions/HashTables/HashTables.php |
— | — | @@ -588,22 +588,39 @@ |
589 | 589 | return ''; |
590 | 590 | } |
591 | 591 | |
| 592 | + global $egHashTablesExpansionEscapeTemplates; |
592 | 593 | $store = self::get( $parser ); |
593 | 594 | |
594 | 595 | $template = trim( $frame->expand($args[0] ) ); |
595 | 596 | $hashId = trim( $frame->expand($args[1] ) ); |
596 | | - $pipeReplacer = isset($args[2]) ? trim( $frame->expand( $args[2] ) ) : '|'; |
| 597 | + if( $egHashTablesExpansionEscapeTemplates === null ) { |
| 598 | + // COMPATIBILITY-MODE |
| 599 | + // third parameter is depreciated since 1.0 in case we can auto-escape |
| 600 | + $pipeReplacer = isset($args[2]) ? trim( $frame->expand( $args[2] ) ) : '|'; |
| 601 | + } |
597 | 602 | |
598 | 603 | if( ! $store->hashExists( $hashId ) ) { |
599 | 604 | return ''; |
600 | 605 | } |
601 | 606 | |
602 | 607 | $params = $store->getHash( $hashId ); |
603 | | - $templateCall = '{{' . $template; |
| 608 | + $templateCall = '{{' . $template; |
604 | 609 | |
605 | | - foreach ($params as $paramKey => $paramValue){ |
606 | | - // replace '{', '}' and '|' to avoid template call manipulation |
607 | | - $paramValue = str_replace( array( '{', '}', '|' ), array( '{', '}', $pipeReplacer ), $paramValue ); |
| 610 | + foreach( $params as $paramKey => $paramValue ){ |
| 611 | + if( $egHashTablesExpansionEscapeTemplates !== null ) { |
| 612 | + // escape all special chars so template call won't get destroyed by user values |
| 613 | + $paramKey = self::escapeForExpansion( $paramKey ); |
| 614 | + $paramValue = self::escapeForExpansion( $paramValue ); |
| 615 | + } else { |
| 616 | + // COMPATIBILITY-MODE |
| 617 | + $replacedValues = str_replace( |
| 618 | + array( '{', '}', '|' ), |
| 619 | + array( '{', '}', $pipeReplacer ), |
| 620 | + array( $paramKey, $paramValue ) |
| 621 | + ); |
| 622 | + $paramKey = $replacedValues[0]; |
| 623 | + $paramValue = $replacedValues[1]; |
| 624 | + } |
608 | 625 | $templateCall .= "|$paramKey=$paramValue"; |
609 | 626 | } |
610 | 627 | $templateCall .= '}}'; |
Index: trunk/extensions/HashTables/RELEASE-NOTES |
— | — | @@ -1,21 +1,24 @@ |
2 | 2 | Changelog: |
3 | 3 | ========== |
4 | 4 | |
5 | | - * (trunk) Version 1.0 |
| 5 | + * (trunk) Version 1.0 alpha |
6 | 6 | This release has lots of internal changes in it. All functions representing a parser funcdtions now |
7 | 7 | use a 'pf_' or 'pfObj_' prefix, are declared static and there are new/changed public functions for |
8 | 8 | interaction with 'HashTables' extension. |
9 | 9 | - Compatbility with other extensions increased by using one hash tables store per Parser instance. |
10 | 10 | - Inclusion of special pages in the middle of the page won't reset all defined hash tables anymore. |
11 | | - - '#hashprint' will handle <includeonly>/<noinclude> correct in case it's used in a template. |
| 11 | + - '#hashprint' will handle '<includeonly>' and '<noinclude>' correct in case it's used in a template. |
12 | 12 | - '#hashprint' will use the languages default comma separator instead of hard-coded ', ' as default. |
13 | 13 | - '#hashprint' will no longer expand the given wiki markup twice. Instead, it will escape special |
14 | 14 | characters of hash values before they will be inserted into the markup. This way it won't be |
15 | 15 | possible anymore that hash values can break the functions output. '$egHashTablesExpansionEscapeTemplates' |
16 | 16 | defines which special characters should be escaped by which template/parser function. It can also |
17 | 17 | be set to null to keep the old behavior as some kind of compatibility mode. |
| 18 | + - '#hashtotemplate' uses the new escaping mechanism (except '$egHashTablesExpansionEscapeTemplates' |
| 19 | + is set to null). Therefore '#hashtotemplate' parameter three is depreciated. |
18 | 20 | - '#hashvalue' will only expand its default when required. |
19 | 21 | |
| 22 | + |
20 | 23 | * November 4, 2011 -- Version 0.7 |
21 | 24 | - buggy behavior in 'hashkeyexists' which led to expanding both arguments 'yes' and 'no' in |
22 | 25 | case custom arguments were given is solved. Now only the one actual case is being expanded. |
— | — | @@ -27,8 +30,8 @@ |
28 | 31 | - some gernal cleanup done. |
29 | 32 | - put into wikimedia.org svn (http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/HashTables/) |
30 | 33 | - distributed under ISC license. |
31 | | - |
32 | 34 | |
| 35 | + |
33 | 36 | * August 3, 2011 -- Version 0.6.3 |
34 | 37 | - minor bug in 'parameterstohash' function solved. |
35 | 38 | |
— | — | @@ -42,8 +45,8 @@ |
43 | 46 | * January 19, 2011 -- Version 0.6 |
44 | 47 | - New public class methods for creating and removing hash tables. Good for use by other extensions. |
45 | 48 | - New experimental function 'hashtotemplate'. |
46 | | - |
47 | | - |
| 49 | + |
| 50 | + |
48 | 51 | * August 3, 2010 -- Version 0.5.1 |
49 | 52 | - Hashinclude didn't trim key and value so keys with ending space ' ' and values with leading |
50 | 53 | space were possible when defining something like {{#hashinclude: a | a = 1}} |
— | — | @@ -58,19 +61,19 @@ |
59 | 62 | * July 20, 2010 -- Version 0.4 |
60 | 63 | - Removed critical bug. Some kind of "Superglobal" HashTables on page imports and job queue jobs. |
61 | 64 | Values were passed from one page to another page. |
62 | | - |
63 | | - |
| 65 | + |
| 66 | + |
64 | 67 | * June 11, 2010 -- Version 0.3 |
65 | 68 | - Third parameter for 'arraytohash' allows to set a key array. |
66 | 69 | - New function 'hashkeyexists'. |
67 | | - |
68 | | - |
| 70 | + |
| 71 | + |
69 | 72 | * June 6, 2010 -- Version 0.2 |
70 | 73 | - New functions 'hashmerge', 'hashmix', 'hashdiff', 'hashinclude' and 'hashexclude'. |
71 | 74 | - New functions if 'ArrayExtension' is available in the wiki: 'hashtoarray' and 'arraytohash'. |
72 | 75 | - New parameter for 'hashprint' which allows to define the print order thru an array. |
73 | | - |
74 | | - |
| 76 | + |
| 77 | + |
75 | 78 | * Mai 30, 2010 -- Version 0.1 |
76 | 79 | - First version of HashTables featuring the functions 'hashdefine', 'hashvalue', 'hashsize', |
77 | 80 | 'hashprint', 'hashreset' and 'parameterstohash'. |