|
| 1 | +--TEST-- |
| 2 | +Test common ODBC string functionality |
| 3 | +--EXTENSIONS-- |
| 4 | +odbc |
| 5 | +--FILE-- |
| 6 | +<?php |
| 7 | + |
| 8 | +// 1. No, it's not quoted. |
| 9 | +// 2. Yes, it should be quoted because of the special character in the middle. |
| 10 | +$with_end_curly1 = "foo}bar"; |
| 11 | +// 1. No, the unescaped special character in the middle breaks what would be quoted. |
| 12 | +// 2. Yes, it should be quoted because of the special character in the middle. |
| 13 | +// Note that should_quote doesn't care about if the string is already quoted. |
| 14 | +// That's why you should check if it is quoted first. |
| 15 | +$with_end_curly2 = "{foo}bar}"; |
| 16 | +// 1. Yes, the special characters are escaped, so it's quoted. |
| 17 | +// 2. See $with_end_curly2; should_quote doesn't care about if the string is already quoted. |
| 18 | +$with_end_curly3 = "{foo}}bar}"; |
| 19 | +// 1. No, it's not quoted. |
| 20 | +// 2. It doesn't need to be quoted because of no s |
| 21 | +$with_no_end_curly1 = "foobar"; |
| 22 | +// 1. Yes, it is quoted and any characters are properly escaped. |
| 23 | +// 2. See $with_end_curly2. |
| 24 | +$with_no_end_curly2 = "{foobar}"; |
| 25 | + |
| 26 | +echo "# Is quoted?\n"; |
| 27 | +echo "With end curly brace 1: "; |
| 28 | +var_dump(odbc_connection_string_is_quoted($with_end_curly1)); |
| 29 | +echo "With end curly brace 2: "; |
| 30 | +var_dump(odbc_connection_string_is_quoted($with_end_curly2)); |
| 31 | +echo "With end curly brace 3: "; |
| 32 | +var_dump(odbc_connection_string_is_quoted($with_end_curly3)); |
| 33 | +echo "Without end curly brace 1: "; |
| 34 | +var_dump(odbc_connection_string_is_quoted($with_no_end_curly1)); |
| 35 | +echo "Without end curly brace 2: "; |
| 36 | +var_dump(odbc_connection_string_is_quoted($with_no_end_curly2)); |
| 37 | + |
| 38 | +echo "# Should quote?\n"; |
| 39 | +echo "With end curly brace 1: "; |
| 40 | +var_dump(odbc_connection_string_should_quote($with_end_curly1)); |
| 41 | +echo "With end curly brace 2: "; |
| 42 | +var_dump(odbc_connection_string_should_quote($with_end_curly2)); |
| 43 | +echo "With end curly brace 3: "; |
| 44 | +var_dump(odbc_connection_string_should_quote($with_end_curly3)); |
| 45 | +echo "Without end curly brace 1: "; |
| 46 | +var_dump(odbc_connection_string_should_quote($with_no_end_curly1)); |
| 47 | +echo "Without end curly brace 2: "; |
| 48 | +var_dump(odbc_connection_string_should_quote($with_no_end_curly2)); |
| 49 | + |
| 50 | +echo "# Quote?\n"; |
| 51 | +echo "With end curly brace 1: "; |
| 52 | +var_dump(odbc_connection_string_quote($with_end_curly1)); |
| 53 | +echo "With end curly brace 2: "; |
| 54 | +var_dump(odbc_connection_string_quote($with_end_curly2)); |
| 55 | +echo "With end curly brace 3: "; |
| 56 | +var_dump(odbc_connection_string_quote($with_end_curly3)); |
| 57 | +echo "Without end curly brace 1: "; |
| 58 | +var_dump(odbc_connection_string_quote($with_no_end_curly1)); |
| 59 | +echo "Without end curly brace 2: "; |
| 60 | +var_dump(odbc_connection_string_quote($with_no_end_curly2)); |
| 61 | + |
| 62 | +?> |
| 63 | +--EXPECTF-- |
| 64 | +# Is quoted? |
| 65 | +With end curly brace 1: bool(false) |
| 66 | +With end curly brace 2: bool(false) |
| 67 | +With end curly brace 3: bool(true) |
| 68 | +Without end curly brace 1: bool(false) |
| 69 | +Without end curly brace 2: bool(true) |
| 70 | +# Should quote? |
| 71 | +With end curly brace 1: bool(true) |
| 72 | +With end curly brace 2: bool(true) |
| 73 | +With end curly brace 3: bool(true) |
| 74 | +Without end curly brace 1: bool(false) |
| 75 | +Without end curly brace 2: bool(true) |
| 76 | +# Quote? |
| 77 | +With end curly brace 1: string(10) "{foo}}bar}" |
| 78 | +With end curly brace 2: string(13) "{{foo}}bar}}}" |
| 79 | +With end curly brace 3: string(15) "{{foo}}}}bar}}}" |
| 80 | +Without end curly brace 1: string(8) "{foobar}" |
| 81 | +Without end curly brace 2: string(11) "{{foobar}}}" |
0 commit comments