1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
|
[- $r = shift -]
<html>
<head>
<title>Some tests for Embperl escaping</title>
</head>
<body>
Here it starts with some HTML Text<P>
First of all assign a value:
[- $a = '(this is the value in $a)' -] <BR>
Now we have some 'Umlaute':
[- $b = "$a äöü???<\&+ " -]
[- $id = "abcdefghijklmnopqrstuvwxyz" ; $text = "This is a text ? \& + - %21" -]
Now lets look what we are getting from this:<BR>
[+ $a +] [+ $b +]<BR>
What is the EscMode? [+ $escmode +]
Let's set the EscMode to [+ $escmode = 3 +]
What is the EscMode now? [+ $escmode +]
Now a Url: <A HREF="http://localhost/tests?id=[+%20$id +]&text=[+$text+]">Here it goes</A>
A Tag 2: <A HREF="http://localhost/tests?id=[+%20$id +]&text=[+$text+]" TARGET="http://localhost/tests?id=[+$id +]&text=[+$text+]">a2</A>
A Tag 3: <A TARGET="http://localhost/tests?id=[+$id +]&text=[+$text+]" HREF="http://localhost/tests?id=[+%20$id +]&text=[+$text+]" TARGET="http://localhost/tests?id=[+ $id +]&text=[+$text+]">a3</A>
A Tag 4: <A TARGET="http://localhost/tests?id=[+ $id +]&text=[+$text+]" HREF="http://localhost/tests?id=[+%20$id +]&text=[+$text+]">a4</A>
A Tag 5: <A TARGET="http://localhost/tests?id=[+ $id +]&text=[+$text+]">a5</A>
A Tag 6: <A>a6</A>
A Tag 7: <A HREF="7">x</A>
A Tag 8: <A TARGET=8 HREF="8">x</A>
A Tag 9: <A HREF="9" TARGET="9">x</A>
A Tag 10: <A TARGET="10" HREF="10" TARGET="10">x</A>
A Tag 11: <A HREF="11" >x</A>
A Tag 12: <A HREF=12>x</A>
A Tag 12b: <A HREF=12b >x</A>
A Tag 13: <A HREF="[+ "abcd"+]%20[+ "%3e" +]">x</A>
A Tag 14: <A HREF="[+ "abcd"+]%20[+ ">" +]">x</A>
FRAME: <FRAME SRC="http://localhost/tests?id=[+%20$id +]&text=[+$text+]" name="%20foo">
IFRAME: <IFRAME SRC="http://localhost/tests?id=[+%20$id +]&text=[+$text+]" name="%20foo">
EMBED: <EMBED SRC="http://localhost/tests?id=[+%20$id +]&text=[+$text+]" name="%20foo">
LAYER: <LAYER SRC="http://localhost/tests?id=[+%20$id +]&text=[+$text+]" name="%20foo">
IMG: <IMG SRC="http://localhost/tests?id=[+%20$id +]&text=[+$text+]" name="%20foo">
FORM: <FORM action="http://localhost/tests?id=[+%20$id +]&text=[+$text+]" name="%20foo">
[- %A = (A => 1, B => 2) ; @A = (X, 9, Y, 8, Z, 7) -]
Hash in A <A HREF="http://localhost/tests?[+ [ %A ] +]">
Array in A <A HREF="http://localhost/tests?[+ \@A +]">
[- %H = (A => 1, B => 2) ; @H = (X, 9, Y, 8, Z, 7) -]
Hash in H <A HREF="http://localhost/tests?[+ \\%H +]">
Array in H <A HREF="http://localhost/tests?[+ scalar { @H } +]">
[-
%fdat = ( par1 => 1, par2 => 2 );
-]
<a href="tst.html?[+ \\%fdat +]">1</a>
<a href="tst.html?[+ scalar ({ par3 => 3, %fdat }) +]">2</a>
<a href="tst.html?[+ scalar ({ %fdat }) +]">3</a>
<a href="tst.html?[+ scalar ({ %fdat, par3 => 3 }) +]">4</a>
[+ $escmode = 1 +]
Now lets look what we are getting from this:<BR>
[+ $a +] [+ $b +]<BR>
What is the EscMode? [+ $escmode +]
Now a Url: <A HREF="http://localhost/tests?id=[+%20$id +]&text=[+$text+]">Here it goes</A>
[+ $escmode = 2 +]
Now lets look what we are getting from this:<BR>
[+ $a +] [+ $b +]<BR>
What is the EscMode? [+ $escmode +]
Now a Url: <A HREF="http://localhost/tests?id=[+%20$id +]&text=[+$text+]">Here it goes</A>
[+ $escmode = 0 +]
Now lets look what we are getting from this:<BR>
[+ $a +] [+ $b +]<BR>
What is the EscMode? [+ $escmode +]
Now a Url: <A HREF="http://localhost/tests?id=[+%20$id +]&text=[+$text+]">Here it goes</A>
[+ $escmode = 3 +]
Now lets look what we are getting from this:<BR>
[+ $a +] [+ $b +]<BR>
What is the EscMode? [+ $escmode +]
Now a Url: <A HREF="http://localhost/tests?id=[+%20$id +]&text=[+$text+]">Here it goes</A>
What is the EscMode? [+ $escmode +]
[+ $escmode = 15 +]
Now lets look what we are getting from this:<BR>
[+ $a +] [+ $b +] [+ q{'"<>} +]<BR>
What is the EscMode? [+ $escmode +]
Now a Url: <A HREF="http://localhost/tests?id=[+%20$id +]&text=[+$text+] [+ q{'"<>} +]">Here it goes</A>
What is the EscMode? [+ $escmode +]
[!
sub foo($)
{
my @name ;
my @data ;
$name[0] = 'abcd' ;
$data[0] = 'xyz' ;
my $bar = $_[0];
return "file.html?name=$name[$bar]&data=$data[$bar]";
}
!]
[+ foo (0) +]
Now we localy set $escmode:<BR>
[+ do { local $escmode = 0 ; $b . " \\\\<a>" } +]<BR>
[+ do { local $escmode = 1 ; $b . " \\\\<a>" } +]<BR>
[+ do { local $escmode = 2 ; $b . " \\\\<a>" } +]<BR>
[+ do { local $escmode = 3 ; $b . " \\\\<a>" } +]<BR>
[+ do { local $escmode = 4 ; $b . " \\\\<a>" } +]<BR>
[+ do { local $escmode = 5 ; $b . " \\\\<a>" } +]<BR>
[+ do { local $escmode = 6 ; $b . " \\\\<a>" } +]<BR>
[+ do { local $escmode = 7 ; $b . " \\\\<a>" } +]<BR>
Same without local:
[+ $escmode = 0 , $b . " \\\\<a>" +]<BR>
[+ $escmode = 1 , $b . " \\\\<a>" +]<BR>
[+ $escmode = 2 , $b . " \\\\<a>" +]<BR>
[+ $escmode = 3 , $b . " \\\\<a>" +]<BR>
[+ $escmode = 4 , $b . " \\\\<a>" +]<BR>
[+ $escmode = 5 , $b . " \\\\<a>" +]<BR>
[+ $escmode = 6 , $b . " \\\\<a>" +]<BR>
[+ $escmode = 7 , $b . " \\\\<a>" +]<BR>
Control Chars 0x80-0x9f:
[+ do { local $escmode = 7 ; foreach (127..160) { $cc .= chr ($_) }; $cc } +]<BR>
Control Chars 129 & 130:
[+ do { local $escmode = 7 ; "‚" } +]<BR>
[+ $n = 'My Name ' , $escmode = 0 +]
<A HREF='http://host/script?name=[+ $escmode=3, $n +]'>
<A HREF='http://host/script?name=[+ $n+]'>
[+ $escmode = 0 +]
<A HREF='http://host/script?name=[+ do { local $escmode=3; $n } +]'>
<A HREF='http://host/script?name=[+ $n +]'>
<br>
We can avoid interpreting [[- foo -] with a double [[[[ <br>
This should also work for [[* foo *] <br>
<A HREF="[+ "abcd"+]%20[+ "%3e" +]">x</A>
[- $dat = [[1], [2], [3]] -]
<table>
<TR>
<TD><a href="[+$dat->[$row][0]+]">Link</a></TD>
</TR>
</table>
<table>
<TR>
<TD><a href="[+$dat-%3e[$row][0]+]">Link</a></TD>
</TR>
</table>
Escape method:
[- $escmode = 0 -]
0: [+ $r -> Escape($b, 0) +]
1: [+ $r -> Escape($b, 1) +]
2: [+ $r -> Escape($b, 2) +]
3: [+ $r -> Escape($b, 3) +]
4: [+ $r -> Escape($b, 4) +]
5: [+ $r -> Escape($b, 5) +]
6: [+ $r -> Escape($b, 6) +]
7: [+ $r -> Escape($b, 7) +]
print OUT:
[-
local $escmode = 7;
print OUT "7: ric\n";
local $escmode = 0;
print OUT "0: ric\n";
-]
[-
$escmode = 7;
print OUT "7: ric\n";
$escmode = 0;
print OUT "0: ric\n";
-]
[-
$escmode = 7;
print OUT "7: ric\n";
-]
[-
$escmode = 0;
print OUT "0: ric\n";
-]
[-
local $escmode = 7;
print OUT "7: ric\n";
-]
[-
local $escmode = 0;
print OUT "0: ric\n";
-]
[-
$find_if =
{ '!Table' => 'interface,router',
'$where' => 'interface.router_id=router.id',
#'!LongNames' => 1,
};
-]
[-
$escmode = 0;
-]
<A HREF="0?[+ $find_if +]">
[-
$escmode = 7;
-]
<A HREF="7?[+ $find_if +]">
[-
$fdat{esc} = 'environment of the <font color="red">Sample Company</font><>&' ;
$fdat{null} = 0 ;
-]
escmode = [+ $escmode = 7 +]
<input name="esc">
<input name="null">
--> my
[!
sub hellomy () {
my $escmode = 0;
print OUT "<b>hello</b><br>\n";
}
!]
[- hellomy(); -]
[- hellomy(); -]
<br><br>reset<br>
[+ "<b>helloin++</b><br>\n" +]
[- hellomy(); -]
[- hellomy(); -]
<br><br>reset<br>
[- hellomy(); hellomy(); -]
--> local
[!
sub hello () {
local $escmode = 0;
print OUT "<b>hello</b><br>\n";
}
!]
[- hello(); -]
[- hello(); -]
<br><br>reset<br>
[+ "<b>helloin++</b><br>\n" +]
[- hello(); -]
[- hello(); -]
<br><br>reset<br>
[- hello(); hello(); -]
[- $escmode=1 -]<a href=[+ do { '&' } +]>html escaped</a>
<a href=[+ do { local $escmode=1; '&' } +]>html escaped?</a>
<a href=[+ do { local $escmode=2; '&' } +]>url escaped</a>
[- $fdat{foobar} = "Don't go there!" -]
[- $escmode = 3; -]
<textarea name="foobar" rows="5" cols="80" wrap="off">[+ $fdat{foobar}
+]</textarea>
[- $escmode = 0; -]
This does not work:
[- $escmode = 3; -]
<textarea name="foobar" rows="5" cols="80" wrap="off"></textarea>
[- $escmode = 0; -]
<P>Ok.<P>
</body>
</html>
|