diff options
author | Karl Williamson <public@khwilliamson.com> | 2014-01-27 10:42:28 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2014-01-27 11:07:18 -0700 |
commit | 445bf929f6118f5f2b0e19171f576c3a6d7ada50 (patch) | |
tree | cab3ea7a043854d09ad59b32342755b1e8b5bffb /utf8.c | |
parent | 1b4a62a4c81dba4bbb281d24fde1c3b7308fdbfe (diff) | |
download | perl-445bf929f6118f5f2b0e19171f576c3a6d7ada50.tar.gz |
Taint more operands with case changes
The documentation says that Perl taints certain operations when subject
to locale rules, such as lc() and ucfirst(). Prior to this commit
there were exceptions when the operand to these functions contained no
characters whose case change actually varied depending on the locale,
for example the empty string or above-Latin1 code points. Changing to
conform to the documentation simplifies the core code, and yields more
consistent results.
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 37 |
1 files changed, 9 insertions, 28 deletions
@@ -1805,7 +1805,7 @@ Perl__to_uni_fold_flags(pTHX_ UV c, U8* p, STRLEN *lenp, const U8 flags) the special flags. */ U8 utf8_c[UTF8_MAXBYTES + 1]; uvchr_to_utf8(utf8_c, c); - return _to_utf8_fold_flags(utf8_c, p, lenp, flags, NULL); + return _to_utf8_fold_flags(utf8_c, p, lenp, flags); } } @@ -2138,12 +2138,10 @@ Instead use L</toUPPER_utf8>. =cut */ /* Not currently externally documented, and subject to change: - * <flags> is set iff locale semantics are to be used for code points < 256 - * <tainted_ptr> if non-null, *tainted_ptr will be set TRUE iff locale rules - * were used in the calculation; otherwise unchanged. */ + * <flags> is set iff locale semantics are to be used for code points < 256 */ UV -Perl__to_utf8_upper_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, const bool flags, bool* tainted_ptr) +Perl__to_utf8_upper_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, const bool flags) { dVAR; @@ -2188,10 +2186,6 @@ Perl__to_utf8_upper_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, const bool *(ustrp + 1) = UTF8_EIGHT_BIT_LO((U8) result); *lenp = 2; } - - if (tainted_ptr) { - *tainted_ptr = TRUE; - } return result; } @@ -2206,11 +2200,10 @@ Instead use L</toTITLE_utf8>. * <flags> is set iff locale semantics are to be used for code points < 256 * Since titlecase is not defined in POSIX, uppercase is used instead * for these/ - * <tainted_ptr> if non-null, *tainted_ptr will be set TRUE iff locale rules - * were used in the calculation; otherwise unchanged. */ + */ UV -Perl__to_utf8_title_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, const bool flags, bool* tainted_ptr) +Perl__to_utf8_title_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, const bool flags) { dVAR; @@ -2256,9 +2249,6 @@ Perl__to_utf8_title_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, const bool *lenp = 2; } - if (tainted_ptr) { - *tainted_ptr = TRUE; - } return result; } @@ -2270,12 +2260,10 @@ Instead use L</toLOWER_utf8>. =cut */ /* Not currently externally documented, and subject to change: - * <flags> is set iff locale semantics are to be used for code points < 256 - * <tainted_ptr> if non-null, *tainted_ptr will be set TRUE iff locale rules - * were used in the calculation; otherwise unchanged. */ + * <flags> is set iff locale semantics are to be used for code points < 256 */ UV -Perl__to_utf8_lower_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, const bool flags, bool* tainted_ptr) +Perl__to_utf8_lower_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, const bool flags) { UV result; @@ -2322,9 +2310,6 @@ Perl__to_utf8_lower_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, const bool *lenp = 2; } - if (tainted_ptr) { - *tainted_ptr = TRUE; - } return result; } @@ -2344,11 +2329,10 @@ Instead use L</toFOLD_utf8>. * otherwise simple folds * bit FOLD_FLAGS_NOMIX_ASCII is set iff folds of non-ASCII to ASCII are * prohibited - * <tainted_ptr> if non-null, *tainted_ptr will be set TRUE iff locale rules - * were used in the calculation; otherwise unchanged. */ + */ UV -Perl__to_utf8_fold_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, U8 flags, bool* tainted_ptr) +Perl__to_utf8_fold_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, U8 flags) { dVAR; @@ -2453,9 +2437,6 @@ Perl__to_utf8_fold_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, U8 flags, b *lenp = 2; } - if (tainted_ptr) { - *tainted_ptr = TRUE; - } return result; return_long_s: |