Author: bernhard
Date: Mon Jul 21 04:46:28 2008
New Revision: 29649
Modified:
trunk/languages/pipp/src/pct/quote_expression.pir
trunk/languages/pipp/t/php/strings.t
Log:
[Pipp PCT] Check the maximal number of digits in hex and octal escape sequences.
Modified: trunk/languages/pipp/src/pct/quote_expression.pir
==============================================================================
--- trunk/languages/pipp/src/pct/quote_expression.pir (original)
+++ trunk/languages/pipp/src/pct/quote_expression.pir Mon Jul 21 04:46:28 2008
@@ -344,13 +344,15 @@
goto scan_loop
- .local int base, decnum
+ .local int base, decnum, max_digits, cnt_digit
scan_octal:
base = 8
+ max_digits = 3
pos += 1 # octal digits come right after the '\'
goto got_base
scan_hex:
base = 16
+ max_digits = 2
pos += 2 # skip the 'x'
got_base:
## Handle hex and octal escapes.
@@ -359,8 +361,11 @@
## that follow to compute the decimal value of codepoints,
## and add the codepoints to our literal.
decnum = 0
+ cnt_digit = 1
$S0 = substr target, pos, 1
scan_xo_char_loop:
+ if cnt_digit > max_digits goto scan_xo_char_end
+ inc cnt_digit
$S0 = substr target, pos, 1
$I0 = index '0123456789abcdef0123456789ABCDEF', $S0
if $I0 < 0 goto scan_xo_char_end
Modified: trunk/languages/pipp/t/php/strings.t
==============================================================================
--- trunk/languages/pipp/t/php/strings.t (original)
+++ trunk/languages/pipp/t/php/strings.t Mon Jul 21 04:46:28 2008
@@ -282,7 +282,7 @@
ABC ABC
END_EXPECTED
-language_output_is( 'Pipp', <<'END_CODE', <<"END_EXPECTED", 'hex escapes
followed by a digit', todo => 'not implemented yet' );
+language_output_is( 'Pipp', <<'END_CODE', <<"END_EXPECTED", 'hex escapes
followed by a digit' );
<?php
echo "A1B2C3 \x411\x422\x433", "\n";
@@ -292,7 +292,7 @@
A1B2C3 A1B2C3
END_EXPECTED
-language_output_is( 'Pipp', <<'END_CODE', <<"END_EXPECTED", 'octal escapes
followed by a digit', todo => 'not implemented yet' );
+language_output_is( 'Pipp', <<'END_CODE', <<"END_EXPECTED", 'octal escapes
followed by a digit' );
<?php
echo "A1B2C3 \1011\1022\1033", "\n";