@@ -63,11 +63,13 @@ class Debugger {
63
63
'trace ' => '<pre class="stack-trace">{:trace}</pre> ' ,
64
64
'code ' => '' ,
65
65
'context ' => '' ,
66
- 'links ' => array ()
66
+ 'links ' => array (),
67
+ 'escapeContext ' => true ,
67
68
),
68
69
'html ' => array (
69
70
'trace ' => '<pre class="cake-error trace"><b>Trace</b> <p>{:trace}</p></pre> ' ,
70
- 'context ' => '<pre class="cake-error context"><b>Context</b> <p>{:context}</p></pre> '
71
+ 'context ' => '<pre class="cake-error context"><b>Context</b> <p>{:context}</p></pre> ' ,
72
+ 'escapeContext ' => true ,
71
73
),
72
74
'txt ' => array (
73
75
'error ' => "{:error}: {:code} :: {:description} on line {:line} of {:path} \n{:info} " ,
@@ -716,7 +718,7 @@ public function outputError($data) {
716
718
$ info = '' ;
717
719
718
720
foreach ((array )$ data ['context ' ] as $ var => $ value ) {
719
- $ context [] = "\${$ var }\t = \t " . $ this ->exportVar ($ value , 1 );
721
+ $ context [] = "\${$ var } = " . $ this ->exportVar ($ value , 1 );
720
722
}
721
723
722
724
switch ($ this ->_outputFormat ) {
@@ -731,30 +733,29 @@ public function outputError($data) {
731
733
$ data ['trace ' ] = $ trace ;
732
734
$ data ['id ' ] = 'cakeErr ' . uniqid ();
733
735
$ tpl = array_merge ($ this ->_templates ['base ' ], $ this ->_templates [$ this ->_outputFormat ]);
734
- $ insert = array ('context ' => join ("\n" , $ context )) + $ data ;
735
-
736
- $ detect = array ('context ' );
737
736
738
737
if (isset ($ tpl ['links ' ])) {
739
738
foreach ($ tpl ['links ' ] as $ key => $ val ) {
740
- if (in_array ($ key , $ detect ) && empty ($ insert [$ key ])) {
741
- continue ;
742
- }
743
- $ links [$ key ] = String::insert ($ val , $ insert , $ insertOpts );
739
+ $ links [$ key ] = String::insert ($ val , $ data , $ insertOpts );
744
740
}
745
741
}
746
742
747
- foreach (array ('code ' , 'context ' , 'trace ' ) as $ key ) {
748
- if (empty ($ $ key ) || !isset ($ tpl [$ key ])) {
743
+ if (!empty ($ tpl ['escapeContext ' ])) {
744
+ $ context = h ($ context );
745
+ }
746
+
747
+ $ infoData = compact ('code ' , 'context ' , 'trace ' );
748
+ foreach ($ infoData as $ key => $ value ) {
749
+ if (empty ($ value ) || !isset ($ tpl [$ key ])) {
749
750
continue ;
750
751
}
751
- if (is_array ($ $ key )) {
752
- $ $ key = join ("\n" , $ $ key );
752
+ if (is_array ($ value )) {
753
+ $ value = join ("\n" , $ value );
753
754
}
754
- $ info .= String::insert ($ tpl [$ key ], compact ($ key ) + $ insert , $ insertOpts );
755
+ $ info .= String::insert ($ tpl [$ key ], array ($ key => $ value ) + $ data , $ insertOpts );
755
756
}
756
757
$ links = join (' ' , $ links );
757
- unset( $ data [ ' context ' ]);
758
+
758
759
if (isset ($ tpl ['callback ' ]) && is_callable ($ tpl ['callback ' ])) {
759
760
return call_user_func ($ tpl ['callback ' ], $ data , compact ('links ' , 'info ' ));
760
761
}
0 commit comments