diff options
Diffstat (limited to '')
-rw-r--r-- | src/tests/keywords/escape | 67 | ||||
-rw-r--r-- | src/tests/keywords/escape-sequences | 95 |
2 files changed, 162 insertions, 0 deletions
diff --git a/src/tests/keywords/escape b/src/tests/keywords/escape new file mode 100644 index 0000000..5d0b3bc --- /dev/null +++ b/src/tests/keywords/escape @@ -0,0 +1,67 @@ +# +# PRE: update if xlat-attr-index +# +update request { + control:Cleartext-Password := 'hello' + reply:Filter-Id := "filter" + + Tmp-String-0 := '@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /' + Tmp-String-1 := '±§#$%^&+={[}];<,>?`|"' + Tmp-String-2 := '™¥¤' + Tmp-String-3 := '=C2=B1=C2=A7=23=24=25=5E=26=2B=3D=7B=5B=7D=5D=3B=3C=2C=3E=3F=60=7C=22' + Tmp-String-4 := '=E2=84=A2=C2=A5=C2=A4' + Tmp-String-5 := '=40=61=62=63=64=65=66=67' + + # Mixture of safe and unsafe chars + Tmp-String-6 := 'ŒČÿ' + Tmp-String-7 := 'Œ=C4=8Cÿ' +} + +if (<string>"%{escape:%{request:Tmp-String-0}}" != &Tmp-String-0) { + update reply { + Filter-Id += 'Fail 1' + } +} + +if (<string>"%{escape:%{request:Tmp-String-1}}" != &Tmp-String-3) { + update reply { + Filter-Id += 'Fail 2' + } +} + +if (<string>"%{escape:%{request:Tmp-String-2}}" != &Tmp-String-4) { + update reply { + Filter-Id += 'Fail 3' + } +} + +if (<string>"%{unescape:%{request:Tmp-String-0}}" != &Tmp-String-0) { + update reply { + Filter-Id += 'Fail 4' + } +} + +if (<string>"%{unescape:%{request:Tmp-String-3}}" != "%{Tmp-String-1}") { + update reply { + Filter-Id += 'Fail 5' + } +} + +if (<string>"%{unescape:%{request:Tmp-String-4}}" != &Tmp-String-2) { + update reply { + Filter-Id += 'Fail 6' + } +} + +if (<string>"%{escape:%{request:Tmp-String-6}}" != &Tmp-String-7) { + update reply { + Filter-Id += 'Fail 7' + } +} + +if (<string>"%{unescape:%{request:Tmp-String-7}}" != &Tmp-String-6) { + update reply { + Filter-Id += 'Fail 8' + } +} + diff --git a/src/tests/keywords/escape-sequences b/src/tests/keywords/escape-sequences new file mode 100644 index 0000000..967656d --- /dev/null +++ b/src/tests/keywords/escape-sequences @@ -0,0 +1,95 @@ +# +# PRE: update if xlat-attr-index +# +update request { + control:Cleartext-Password := 'hello' + Tmp-Octets-0 := 0x69206861766520736361727920656d626564646564207468696e67730020696e73696465206d65 + Tmp-Octets-1 := 0x30783031013078303707307830410A307830440D222230786230b0C2b0 + Tmp-String-0 := "i have scary embedded things\000 inside me" + Tmp-String-0 += "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°" + + # and again with single quoted strings. + # unlike other languages, \r, \t, and \n have meaning inside of 'string' + Tmp-String-1 := 'i have scary embedded things\000 inside me' + Tmp-String-1 += '0x01\0010x07\0070x0A\n0x0D\r""0xb0\260°' + + Tmp-String-2 := 'i have scary embedded things\000 inside me' + Tmp-String-2 += "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°" + + reply:Filter-Id := "filter" +} + + +if ("%{length:&Tmp-String-0}" != 39) { + update reply { + Filter-Id += 'fail l-0' + } +} + +if ("%{length:&Tmp-String-1}" != 42) { + update reply { + Filter-Id += 'fail l-1' + } +} + +if ("%{string:Tmp-Octets-0}" != "i have scary embedded things\000 inside me") { + update reply { + Filter-Id += 'fail 1' + } +} + +if (&Tmp-String-0 != "i have scary embedded things\000 inside me") { + update reply { + Filter-Id += 'fail 2' + } +} + +if ("%{string:Tmp-Octets-1}" != "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°") { + update reply { + Filter-Id += 'fail 3' + } +} + +if ("%{Tmp-String-0[0]}" != "i have scary embedded things\000 inside me") { + update reply { + Filter-Id += 'fail 4' + } +} + +if ("%{Tmp-String-0[1]}" != "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°") { + update reply { + Filter-Id += 'fail 5' + } +} + +# And another slightly different codepath... +if ("%{Tmp-String-0[*]}" != "i have scary embedded things\000 inside me,0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°") { + update reply { + Filter-Id += 'fail 6' + } +} + +if (&Tmp-String-0[0] != &Tmp-String-0[0]) { + update reply { + Filter-Id += 'fail 7' + } +} + +# +# This seems weird... double escapes for most things, but single escapes +# for the quotation marks. +# +if ("%{Tmp-String-2[1]}" != "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°") { + update reply { + Filter-Id += 'fail 8' + } +} + +# +# And again as an attribute reference +# +if (&Tmp-String-2[1] != "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°") { + update reply { + Filter-Id += 'fail 9' + } +} |