Completed
Push — master ( bf2930...494091 )
by David
07:08 queued 03:26
created
lib/Dwoo/Compiler.php 1 patch
Switch Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -769,13 +769,13 @@  discard block
 block discarded – undo
769 769
                         $search = array('{<\?.*?\?>}', '{<%.*?%>}');
770 770
                     }
771 771
                     switch ($this->securityPolicy->getPhpHandling()) {
772
-                        case SecurityPolicy::PHP_ALLOW:
773
-                            break;
774
-                        case SecurityPolicy::PHP_ENCODE:
775
-                            $tpl = preg_replace_callback($search, array($this, 'phpTagEncodingHelper'), $tpl);
776
-                            break;
777
-                        case SecurityPolicy::PHP_REMOVE:
778
-                            $tpl = preg_replace($search, '', $tpl);
772
+                    case SecurityPolicy::PHP_ALLOW:
773
+                        break;
774
+                    case SecurityPolicy::PHP_ENCODE:
775
+                        $tpl = preg_replace_callback($search, array($this, 'phpTagEncodingHelper'), $tpl);
776
+                        break;
777
+                    case SecurityPolicy::PHP_REMOVE:
778
+                        $tpl = preg_replace($search, '', $tpl);
779 779
                     }
780 780
                 }
781 781
             }
@@ -875,42 +875,42 @@  discard block
 block discarded – undo
875 875
             }
876 876
 
877 877
             switch ($type) {
878
-                case Core::BLOCK_PLUGIN:
879
-                case Core::CLASS_PLUGIN:
880
-                    if (class_exists('Plugin' . $plugin) !== false) {
881
-                        $output .= "if (class_exists('" . "Plugin" . $plugin . "')===false)".
882
-                        "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
883
-                    } else {
884
-                        $output .= "if (class_exists('" . Core::NAMESPACE_PLUGINS_BLOCKS . "Plugin" . $plugin . "')===false)".
885
-                        "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
886
-                    }
887
-                    break;
888
-                case Core::FUNC_PLUGIN:
889
-                    if (function_exists('Plugin' . $plugin) !== false) {
890
-                        $output .= "if (function_exists('" . "Plugin" . $plugin . "')===false)".
891
-                        "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
892
-                    } else {
893
-                        $output .= "if (function_exists('" . Core::NAMESPACE_PLUGINS_FUNCTIONS . "Plugin" . $plugin . "')===false)".
894
-                        "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
895
-                    }
896
-                    break;
897
-                case Core::SMARTY_MODIFIER:
898
-                    $output .= "if (function_exists('smarty_modifier_$plugin')===false)".
899
-                    "\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
900
-                    break;
901
-                case Core::SMARTY_FUNCTION:
902
-                    $output .= "if (function_exists('smarty_function_$plugin')===false)".
903
-                    "\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
904
-                    break;
905
-                case Core::SMARTY_BLOCK:
906
-                    $output .= "if (function_exists('smarty_block_$plugin')===false)".
907
-                    "\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
908
-                    break;
909
-                case Core::PROXY_PLUGIN:
910
-                    $output .= $this->getDwoo()->getPluginProxy()->getLoader($plugin);
911
-                    break;
912
-                default:
913
-                    throw new CompilationException($this, 'Type error for ' . $plugin . ' with type' . $type);
878
+            case Core::BLOCK_PLUGIN:
879
+            case Core::CLASS_PLUGIN:
880
+                if (class_exists('Plugin' . $plugin) !== false) {
881
+                    $output .= "if (class_exists('" . "Plugin" . $plugin . "')===false)".
882
+                    "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
883
+                } else {
884
+                    $output .= "if (class_exists('" . Core::NAMESPACE_PLUGINS_BLOCKS . "Plugin" . $plugin . "')===false)".
885
+                    "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
886
+                }
887
+                break;
888
+            case Core::FUNC_PLUGIN:
889
+                if (function_exists('Plugin' . $plugin) !== false) {
890
+                    $output .= "if (function_exists('" . "Plugin" . $plugin . "')===false)".
891
+                    "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
892
+                } else {
893
+                    $output .= "if (function_exists('" . Core::NAMESPACE_PLUGINS_FUNCTIONS . "Plugin" . $plugin . "')===false)".
894
+                    "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
895
+                }
896
+                break;
897
+            case Core::SMARTY_MODIFIER:
898
+                $output .= "if (function_exists('smarty_modifier_$plugin')===false)".
899
+                "\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
900
+                break;
901
+            case Core::SMARTY_FUNCTION:
902
+                $output .= "if (function_exists('smarty_function_$plugin')===false)".
903
+                "\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
904
+                break;
905
+            case Core::SMARTY_BLOCK:
906
+                $output .= "if (function_exists('smarty_block_$plugin')===false)".
907
+                "\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
908
+                break;
909
+            case Core::PROXY_PLUGIN:
910
+                $output .= $this->getDwoo()->getPluginProxy()->getLoader($plugin);
911
+                break;
912
+            default:
913
+                throw new CompilationException($this, 'Type error for ' . $plugin . ' with type' . $type);
914 914
             }
915 915
         }
916 916
 
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginIf.php 1 patch
Switch Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -70,164 +70,164 @@
 block discarded – undo
70 70
             }
71 71
             switch ($vmod) {
72 72
 
73
-                case 'and':
74
-                    if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
75
-                        $p[] = '&&';
76
-                    } else {
77
-                        $p[] = $v;
78
-                    }
79
-                    break;
80
-                case 'or':
81
-                    if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
82
-                        $p[] = '||';
83
-                    } else {
84
-                        $p[] = $v;
85
-                    }
86
-                    break;
87
-                case 'xor':
88
-                    if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
89
-                        $p[] = '^';
90
-                    } else {
91
-                        $p[] = $v;
92
-                    }
93
-                    break;
94
-                case 'eq':
95
-                    if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
96
-                        $p[] = '==';
97
-                    } else {
98
-                        $p[] = $v;
99
-                    }
100
-                    break;
101
-                case 'ne':
102
-                case 'neq':
103
-                    if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
104
-                        $p[] = '!=';
105
-                    } else {
106
-                        $p[] = $v;
107
-                    }
108
-                    break;
109
-                case 'gte':
110
-                case 'ge':
111
-                    if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
112
-                        $p[] = '>=';
113
-                    } else {
114
-                        $p[] = $v;
115
-                    }
116
-                    break;
117
-                case 'lte':
118
-                case 'le':
119
-                    if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
120
-                        $p[] = '<=';
121
-                    } else {
122
-                        $p[] = $v;
123
-                    }
124
-                    break;
125
-                case 'gt':
126
-                    if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
127
-                        $p[] = '>';
128
-                    } else {
129
-                        $p[] = $v;
130
-                    }
131
-                    break;
132
-                case 'lt':
133
-                    if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
134
-                        $p[] = '<';
135
-                    } else {
136
-                        $p[] = $v;
137
-                    }
138
-                    break;
139
-                case 'mod':
140
-                    if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
141
-                        $p[] = '%';
142
-                    } else {
143
-                        $p[] = $v;
144
-                    }
145
-                    break;
146
-                case 'not':
147
-                    if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
148
-                        $p[] = '!';
149
-                    } else {
150
-                        $p[] = $v;
151
-                    }
152
-                    break;
153
-                case '<>':
73
+            case 'and':
74
+                if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
75
+                    $p[] = '&&';
76
+                } else {
77
+                    $p[] = $v;
78
+                }
79
+                break;
80
+            case 'or':
81
+                if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
82
+                    $p[] = '||';
83
+                } else {
84
+                    $p[] = $v;
85
+                }
86
+                break;
87
+            case 'xor':
88
+                if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
89
+                    $p[] = '^';
90
+                } else {
91
+                    $p[] = $v;
92
+                }
93
+                break;
94
+            case 'eq':
95
+                if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
96
+                    $p[] = '==';
97
+                } else {
98
+                    $p[] = $v;
99
+                }
100
+                break;
101
+            case 'ne':
102
+            case 'neq':
103
+                if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
154 104
                     $p[] = '!=';
105
+                } else {
106
+                    $p[] = $v;
107
+                }
108
+                break;
109
+            case 'gte':
110
+            case 'ge':
111
+                if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
112
+                    $p[] = '>=';
113
+                } else {
114
+                    $p[] = $v;
115
+                }
116
+                break;
117
+            case 'lte':
118
+            case 'le':
119
+                if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
120
+                    $p[] = '<=';
121
+                } else {
122
+                    $p[] = $v;
123
+                }
124
+                break;
125
+            case 'gt':
126
+                if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
127
+                    $p[] = '>';
128
+                } else {
129
+                    $p[] = $v;
130
+                }
131
+                break;
132
+            case 'lt':
133
+                if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
134
+                    $p[] = '<';
135
+                } else {
136
+                    $p[] = $v;
137
+                }
138
+                break;
139
+            case 'mod':
140
+                if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
141
+                    $p[] = '%';
142
+                } else {
143
+                    $p[] = $v;
144
+                }
145
+                break;
146
+            case 'not':
147
+                if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
148
+                    $p[] = '!';
149
+                } else {
150
+                    $p[] = $v;
151
+                }
152
+                break;
153
+            case '<>':
154
+                $p[] = '!=';
155
+                break;
156
+            case '==':
157
+            case '!=':
158
+            case '>=':
159
+            case '<=':
160
+            case '>':
161
+            case '<':
162
+            case '===':
163
+            case '!==':
164
+            case '%':
165
+            case '!':
166
+            case '^':
167
+                $p[] = $vmod;
168
+                break;
169
+            case 'is':
170
+                if ($tokens[$k] !== Compiler::T_UNQUOTED_STRING) {
171
+                    $p[] = $v;
155 172
                     break;
156
-                case '==':
157
-                case '!=':
158
-                case '>=':
159
-                case '<=':
160
-                case '>':
161
-                case '<':
162
-                case '===':
163
-                case '!==':
164
-                case '%':
165
-                case '!':
166
-                case '^':
167
-                    $p[] = $vmod;
173
+                }
174
+                if (isset($params[$k + 1]) && strtolower(trim($params[$k + 1], '"\'')) === 'not' && $tokens[$k + 1] === Compiler::T_UNQUOTED_STRING) {
175
+                    $negate = true;
176
+                    next($params);
177
+                } else {
178
+                    $negate = false;
179
+                }
180
+                $ptr = 1 + (int)$negate;
181
+                if ($tokens[$k + $ptr] !== Compiler::T_UNQUOTED_STRING) {
168 182
                     break;
169
-                case 'is':
170
-                    if ($tokens[$k] !== Compiler::T_UNQUOTED_STRING) {
171
-                        $p[] = $v;
172
-                        break;
173
-                    }
174
-                    if (isset($params[$k + 1]) && strtolower(trim($params[$k + 1], '"\'')) === 'not' && $tokens[$k + 1] === Compiler::T_UNQUOTED_STRING) {
175
-                        $negate = true;
176
-                        next($params);
177
-                    } else {
178
-                        $negate = false;
179
-                    }
180
-                    $ptr = 1 + (int)$negate;
181
-                    if ($tokens[$k + $ptr] !== Compiler::T_UNQUOTED_STRING) {
182
-                        break;
183
-                    }
184
-                    if (!isset($params[$k + $ptr])) {
185
-                        $params[$k + $ptr] = '';
186
-                    } else {
187
-                        $params[$k + $ptr] = trim($params[$k + $ptr], '"\'');
188
-                    }
189
-                    switch ($params[$k + $ptr]) {
183
+                }
184
+                if (!isset($params[$k + $ptr])) {
185
+                    $params[$k + $ptr] = '';
186
+                } else {
187
+                    $params[$k + $ptr] = trim($params[$k + $ptr], '"\'');
188
+                }
189
+                switch ($params[$k + $ptr]) {
190 190
 
191
-                        case 'div':
192
-                            if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') {
193
-                                $p[] = ' % ' . $params[$k + $ptr + 2] . ' ' . ($negate ? '!' : '=') . '== 0';
194
-                                next($params);
195
-                                next($params);
196
-                                next($params);
197
-                            } else {
198
-                                throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] div by $b", found ' . $params[$k - 1] . ' is ' . ($negate ? 'not ' : '') . 'div ' . $params[$k + $ptr + 1] . ' ' . $params[$k + $ptr + 2]);
199
-                            }
200
-                            break;
201
-                        case 'even':
202
-                            $a = array_pop($p);
203
-                            if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') {
204
-                                $b   = $params[$k + $ptr + 2];
205
-                                $p[] = '(' . $a . ' / ' . $b . ') % 2 ' . ($negate ? '!' : '=') . '== 0';
206
-                                next($params);
207
-                                next($params);
208
-                            } else {
209
-                                $p[] = $a . ' % 2 ' . ($negate ? '!' : '=') . '== 0';
210
-                            }
211
-                            next($params);
212
-                            break;
213
-                        case 'odd':
214
-                            $a = array_pop($p);
215
-                            if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') {
216
-                                $b   = $params[$k + $ptr + 2];
217
-                                $p[] = '(' . $a . ' / ' . $b . ') % 2 ' . ($negate ? '=' : '!') . '== 0';
218
-                                next($params);
219
-                                next($params);
220
-                            } else {
221
-                                $p[] = $a . ' % 2 ' . ($negate ? '=' : '!') . '== 0';
222
-                            }
223
-                            next($params);
224
-                            break;
225
-                        default:
226
-                            throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] (div|even|odd) [by $b]", found ' . $params[$k - 1] . ' is ' . $params[$k + $ptr + 1]);
227
-                    }
228
-                    break;
191
+                case 'div':
192
+                if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') {
193
+                $p[] = ' % ' . $params[$k + $ptr + 2] . ' ' . ($negate ? '!' : '=') . '== 0';
194
+                next($params);
195
+                next($params);
196
+                next($params);
197
+                } else {
198
+                throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] div by $b", found ' . $params[$k - 1] . ' is ' . ($negate ? 'not ' : '') . 'div ' . $params[$k + $ptr + 1] . ' ' . $params[$k + $ptr + 2]);
199
+                }
200
+                break;
201
+                case 'even':
202
+                $a = array_pop($p);
203
+                if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') {
204
+                $b   = $params[$k + $ptr + 2];
205
+                $p[] = '(' . $a . ' / ' . $b . ') % 2 ' . ($negate ? '!' : '=') . '== 0';
206
+                next($params);
207
+                next($params);
208
+                } else {
209
+                $p[] = $a . ' % 2 ' . ($negate ? '!' : '=') . '== 0';
210
+                }
211
+                next($params);
212
+                break;
213
+                case 'odd':
214
+                $a = array_pop($p);
215
+                if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') {
216
+                $b   = $params[$k + $ptr + 2];
217
+                $p[] = '(' . $a . ' / ' . $b . ') % 2 ' . ($negate ? '=' : '!') . '== 0';
218
+                next($params);
219
+                next($params);
220
+                } else {
221
+                $p[] = $a . ' % 2 ' . ($negate ? '=' : '!') . '== 0';
222
+                }
223
+                next($params);
224
+                break;
229 225
                 default:
230
-                    $p[] = $v;
226
+                throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] (div|even|odd) [by $b]", found ' . $params[$k - 1] . ' is ' . $params[$k + $ptr + 1]);
227
+                }
228
+                    break;
229
+            default:
230
+                $p[] = $v;
231 231
             }
232 232
         }
233 233
 
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginTextformat.php 1 patch
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -62,14 +62,14 @@
 block discarded – undo
62 62
 
63 63
         switch ($style) {
64 64
 
65
-            case 'email':
66
-                $wrap         = 72;
67
-                $indent_first = 0;
68
-                break;
69
-            case 'html':
70
-                $wrap_char   = '<br />';
71
-                $indent_char = $indent_char == "\t" ? '&nbsp;&nbsp;&nbsp;&nbsp;' : '&nbsp;';
72
-                break;
65
+        case 'email':
66
+            $wrap         = 72;
67
+            $indent_first = 0;
68
+            break;
69
+        case 'html':
70
+            $wrap_char   = '<br />';
71
+            $indent_char = $indent_char == "\t" ? '&nbsp;&nbsp;&nbsp;&nbsp;' : '&nbsp;';
72
+            break;
73 73
         }
74 74
 
75 75
         $this->wrap     = (int)$wrap;
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginStrip.php 1 patch
Switch Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -67,12 +67,12 @@
 block discarded – undo
67 67
 
68 68
         $mode = trim($params['mode'], '"\'');
69 69
         switch ($mode) {
70
-            case 'js':
71
-            case 'javascript':
72
-                $content = preg_replace('#(?<!:)//\s[^\r\n]*|/\*.*?\*/#s', '', $content);
70
+        case 'js':
71
+        case 'javascript':
72
+            $content = preg_replace('#(?<!:)//\s[^\r\n]*|/\*.*?\*/#s', '', $content);
73 73
 
74
-            case 'default':
75
-            default:
74
+        case 'default':
75
+        default:
76 76
         }
77 77
         $content = preg_replace(array(
78 78
             "/\n/",
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginAutoEscape.php 1 patch
Switch Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -56,22 +56,22 @@
 block discarded – undo
56 56
         $params = $compiler->getCompiledParams($params);
57 57
         switch (strtolower(trim((string)$params['enabled'], '"\''))) {
58 58
 
59
-            case 'on':
60
-            case 'true':
61
-            case 'enabled':
62
-            case 'enable':
63
-            case '1':
64
-                $enable = true;
65
-                break;
66
-            case 'off':
67
-            case 'false':
68
-            case 'disabled':
69
-            case 'disable':
70
-            case '0':
71
-                $enable = false;
72
-                break;
73
-            default:
74
-                throw new CompilationException($compiler, 'Auto_Escape : Invalid parameter (' . $params['enabled'] . '), valid parameters are "enable"/true or "disable"/false');
59
+        case 'on':
60
+        case 'true':
61
+        case 'enabled':
62
+        case 'enable':
63
+        case '1':
64
+            $enable = true;
65
+            break;
66
+        case 'off':
67
+        case 'false':
68
+        case 'disabled':
69
+        case 'disable':
70
+        case '0':
71
+            $enable = false;
72
+            break;
73
+        default:
74
+            throw new CompilationException($compiler, 'Auto_Escape : Invalid parameter (' . $params['enabled'] . '), valid parameters are "enable"/true or "disable"/false');
75 75
         }
76 76
 
77 77
         self::$stack[] = $compiler->getAutoEscape();
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginMailto.php 1 patch
Switch Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -67,62 +67,62 @@
 block discarded – undo
67 67
     // output
68 68
     switch ($encode) {
69 69
 
70
-        case 'none':
71
-        case null:
72
-            return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
73
-
74
-        case 'js':
75
-        case 'javascript':
76
-            $str = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
77
-            $len = strlen($str);
78
-
79
-            $out = '';
80
-            for ($i = 0; $i < $len; ++ $i) {
81
-                $out .= '%' . bin2hex($str[$i]);
70
+    case 'none':
71
+    case null:
72
+        return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
73
+
74
+    case 'js':
75
+    case 'javascript':
76
+        $str = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
77
+        $len = strlen($str);
78
+
79
+        $out = '';
80
+        for ($i = 0; $i < $len; ++ $i) {
81
+            $out .= '%' . bin2hex($str[$i]);
82
+        }
83
+
84
+        return '<script type="text/javascript">eval(unescape(\'' . $out . '\'));</script>';
85
+
86
+        break;
87
+    case 'javascript_charcode':
88
+    case 'js_charcode':
89
+    case 'jscharcode':
90
+    case 'jschar':
91
+        $str = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
92
+        $len = strlen($str);
93
+
94
+        $out = '<script type="text/javascript">' . "\n<!--\ndocument.write(Str.fromCharCode(";
95
+        for ($i = 0; $i < $len; ++ $i) {
96
+            $out .= ord($str[$i]) . ',';
97
+        }
98
+
99
+        return rtrim($out, ',') . "));\n-->\n</script>\n";
100
+
101
+        break;
102
+
103
+    case 'hex':
104
+        if (strpos($address, '?') !== false) {
105
+            $dwoo->triggerError('Mailto: Hex encoding is not possible with extra attributes, use one of : <em>js, jscharcode or none</em>.', E_USER_WARNING);
106
+        }
107
+
108
+        $out = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;';
109
+        $len = strlen($address);
110
+        for ($i = 0; $i < $len; ++ $i) {
111
+            if (preg_match('#\w#', $address[$i])) {
112
+                $out .= '%' . bin2hex($address[$i]);
113
+            } else {
114
+                $out .= $address[$i];
82 115
             }
116
+        }
117
+        $out .= '" ' . $extra . '>';
118
+        $len = strlen($text);
119
+        for ($i = 0; $i < $len; ++ $i) {
120
+            $out .= '&#x' . bin2hex($text[$i]);
121
+        }
83 122
 
84
-            return '<script type="text/javascript">eval(unescape(\'' . $out . '\'));</script>';
123
+        return $out . '</a>';
85 124
 
86
-            break;
87
-        case 'javascript_charcode':
88
-        case 'js_charcode':
89
-        case 'jscharcode':
90
-        case 'jschar':
91
-            $str = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
92
-            $len = strlen($str);
93
-
94
-            $out = '<script type="text/javascript">' . "\n<!--\ndocument.write(Str.fromCharCode(";
95
-            for ($i = 0; $i < $len; ++ $i) {
96
-                $out .= ord($str[$i]) . ',';
97
-            }
98
-
99
-            return rtrim($out, ',') . "));\n-->\n</script>\n";
100
-
101
-            break;
102
-
103
-        case 'hex':
104
-            if (strpos($address, '?') !== false) {
105
-                $dwoo->triggerError('Mailto: Hex encoding is not possible with extra attributes, use one of : <em>js, jscharcode or none</em>.', E_USER_WARNING);
106
-            }
107
-
108
-            $out = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;';
109
-            $len = strlen($address);
110
-            for ($i = 0; $i < $len; ++ $i) {
111
-                if (preg_match('#\w#', $address[$i])) {
112
-                    $out .= '%' . bin2hex($address[$i]);
113
-                } else {
114
-                    $out .= $address[$i];
115
-                }
116
-            }
117
-            $out .= '" ' . $extra . '>';
118
-            $len = strlen($text);
119
-            for ($i = 0; $i < $len; ++ $i) {
120
-                $out .= '&#x' . bin2hex($text[$i]);
121
-            }
122
-
123
-            return $out . '</a>';
124
-
125
-        default:
126
-            $dwoo->triggerError('Mailto: <em>encode</em> argument is invalid, it must be one of : <em>none (= no value), js, js_charcode or hex</em>', E_USER_WARNING);
125
+    default:
126
+        $dwoo->triggerError('Mailto: <em>encode</em> argument is invalid, it must be one of : <em>none (= no value), js, js_charcode or hex</em>', E_USER_WARNING);
127 127
     }
128 128
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginEscape.php 1 patch
Switch Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -44,51 +44,51 @@
 block discarded – undo
44 44
     }
45 45
 
46 46
     switch ($format) {
47
-        case 'html':
48
-            return htmlspecialchars((string)$value, ENT_QUOTES, $charset);
49
-        case 'htmlall':
50
-            return htmlentities((string)$value, ENT_QUOTES, $charset);
51
-        case 'url':
52
-            return rawurlencode((string)$value);
53
-        case 'urlpathinfo':
54
-            return str_replace('%2F', '/', rawurlencode((string)$value));
55
-        case 'quotes':
56
-            return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value);
57
-        case 'hex':
58
-            $out = '';
59
-            $cnt = strlen((string)$value);
60
-            for ($i = 0; $i < $cnt; ++ $i) {
61
-                $out .= '%' . bin2hex((string)$value[$i]);
62
-            }
47
+    case 'html':
48
+        return htmlspecialchars((string)$value, ENT_QUOTES, $charset);
49
+    case 'htmlall':
50
+        return htmlentities((string)$value, ENT_QUOTES, $charset);
51
+    case 'url':
52
+        return rawurlencode((string)$value);
53
+    case 'urlpathinfo':
54
+        return str_replace('%2F', '/', rawurlencode((string)$value));
55
+    case 'quotes':
56
+        return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value);
57
+    case 'hex':
58
+        $out = '';
59
+        $cnt = strlen((string)$value);
60
+        for ($i = 0; $i < $cnt; ++ $i) {
61
+            $out .= '%' . bin2hex((string)$value[$i]);
62
+        }
63 63
 
64
-            return $out;
65
-        case 'hexentity':
66
-            $out = '';
67
-            $cnt = strlen((string)$value);
68
-            for ($i = 0; $i < $cnt; ++ $i) {
69
-                $out .= '&#x' . bin2hex((string)$value[$i]) . ';';
70
-            }
64
+        return $out;
65
+    case 'hexentity':
66
+        $out = '';
67
+        $cnt = strlen((string)$value);
68
+        for ($i = 0; $i < $cnt; ++ $i) {
69
+            $out .= '&#x' . bin2hex((string)$value[$i]) . ';';
70
+        }
71 71
 
72
-            return $out;
73
-        case 'javascript':
74
-        case 'js':
75
-            return strtr((string)$value, array(
76
-                '\\' => '\\\\',
77
-                "'"  => "\\'",
78
-                '"'  => '\\"',
79
-                "\r" => '\\r',
80
-                "\n" => '\\n',
81
-                '</' => '<\/'
82
-            ));
83
-        case 'mail':
84
-            return str_replace(array(
85
-                '@',
86
-                '.'
87
-            ), array(
88
-                '&nbsp;(AT)&nbsp;',
89
-                '&nbsp;(DOT)&nbsp;'
90
-            ), (string)$value);
91
-        default:
92
-            $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "' . $format . '" given.', E_USER_WARNING);
72
+        return $out;
73
+    case 'javascript':
74
+    case 'js':
75
+        return strtr((string)$value, array(
76
+            '\\' => '\\\\',
77
+            "'"  => "\\'",
78
+            '"'  => '\\"',
79
+            "\r" => '\\r',
80
+            "\n" => '\\n',
81
+            '</' => '<\/'
82
+        ));
83
+    case 'mail':
84
+        return str_replace(array(
85
+            '@',
86
+            '.'
87
+        ), array(
88
+            '&nbsp;(AT)&nbsp;',
89
+            '&nbsp;(DOT)&nbsp;'
90
+        ), (string)$value);
91
+    default:
92
+        $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "' . $format . '" given.', E_USER_WARNING);
93 93
     }
94 94
 }
Please login to merge, or discard this patch.