Re: svn: /php/php-src/ branches/PHP_5_4/ext/intl/grapheme/grapheme_string.c branches/PHP_5_4/ext/intl/tests/bug55562.phpt
trunk/ext/intl/grapheme/grapheme_string.c trunk/ext/intl/tests/bug55562.phpt

From: Date: Sun, 04 Sep 2011 21:44:37 +0000
Subject: Re: svn: /php/php-src/ branches/PHP_5_4/ext/intl/grapheme/grapheme_string.c branches/PHP_5_4/ext/intl/tests/bug55562.phpt
trunk/ext/intl/grapheme/grapheme_string.c trunk/ext/intl/tests/bug55562.phpt
References: 1  Groups: php.cvs 
Request: Send a blank email to [email protected] to get a copy of this message
5.3?

On Sun, Sep 4, 2011 at 8:50 PM, Stanislav Malyshev <[email protected]> wrote:
> stas                                     Sun, 04 Sep 2011 18:50:05 +0000
>
> Revision: http://svn.php.net/viewvc?view=revision&revision=316113
>
> Log:
> fix bug 55562 - make substr always return rest of the string if length is too long
>
> Bug: https://bugs.php.net/55562 (Assigned)
> grapheme_substr() returns false if length parameter is to large
>
> Changed paths:
>    U   php/php-src/branches/PHP_5_4/ext/intl/grapheme/grapheme_string.c
>    A   php/php-src/branches/PHP_5_4/ext/intl/tests/bug55562.phpt
>    U   php/php-src/trunk/ext/intl/grapheme/grapheme_string.c
>    A   php/php-src/trunk/ext/intl/tests/bug55562.phpt
>
> Modified: php/php-src/branches/PHP_5_4/ext/intl/grapheme/grapheme_string.c
> ===================================================================
> --- php/php-src/branches/PHP_5_4/ext/intl/grapheme/grapheme_string.c    2011-09-04 16:33:51 UTC
> (rev 316112)
> +++ php/php-src/branches/PHP_5_4/ext/intl/grapheme/grapheme_string.c    2011-09-04 18:50:05 UTC
> (rev 316113)
> @@ -554,13 +554,17 @@
>                length += iter_val;
>        }
>
> -       if ( UBRK_DONE == sub_str_end_pos && length < 0) {
> +       if ( UBRK_DONE == sub_str_end_pos) {
> +               if(length < 0) {
>
> -               intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: length
> not contained in string", 1 TSRMLS_CC );
> +                       intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr:
> length not contained in string", 1 TSRMLS_CC );
>
> -               efree(ustr);
> -               ubrk_close(bi);
> -               RETURN_FALSE;
> +                       efree(ustr);
> +                       ubrk_close(bi);
> +                       RETURN_FALSE;
> +               } else {
> +                       sub_str_end_pos = ustr_len;
> +               }
>        }
>
>        sub_str = NULL;
>
> Added: php/php-src/branches/PHP_5_4/ext/intl/tests/bug55562.phpt
> ===================================================================
> --- php/php-src/branches/PHP_5_4/ext/intl/tests/bug55562.phpt                           (rev 0)
> +++ php/php-src/branches/PHP_5_4/ext/intl/tests/bug55562.phpt   2011-09-04 18:50:05 UTC (rev
> 316113)
> @@ -0,0 +1,13 @@
> +--TEST--
> +grapheme_substr() - Bug55562 - grapheme_substr() returns false if length parameter is to large
> +--SKIPIF--
> +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
> +--FILE--
> +<?php
> +var_dump(
> +  grapheme_substr('FOK', 1, 20), // expected: OK
> +  grapheme_substr('한국어', 1, 20) //expected: 국어
> +);
> +--EXPECT--
> +string(2) "OK"
> +string(6) "국어"
>
> Modified: php/php-src/trunk/ext/intl/grapheme/grapheme_string.c
> ===================================================================
> --- php/php-src/trunk/ext/intl/grapheme/grapheme_string.c       2011-09-04 16:33:51 UTC (rev
> 316112)
> +++ php/php-src/trunk/ext/intl/grapheme/grapheme_string.c       2011-09-04 18:50:05 UTC (rev
> 316113)
> @@ -554,13 +554,17 @@
>                length += iter_val;
>        }
>
> -       if ( UBRK_DONE == sub_str_end_pos && length < 0) {
> +       if ( UBRK_DONE == sub_str_end_pos) {
> +               if(length < 0) {
>
> -               intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: length
> not contained in string", 1 TSRMLS_CC );
> +                       intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr:
> length not contained in string", 1 TSRMLS_CC );
>
> -               efree(ustr);
> -               ubrk_close(bi);
> -               RETURN_FALSE;
> +                       efree(ustr);
> +                       ubrk_close(bi);
> +                       RETURN_FALSE;
> +               } else {
> +                       sub_str_end_pos = ustr_len;
> +               }
>        }
>
>        sub_str = NULL;
>
> Added: php/php-src/trunk/ext/intl/tests/bug55562.phpt
> ===================================================================
> --- php/php-src/trunk/ext/intl/tests/bug55562.phpt                              (rev 0)
> +++ php/php-src/trunk/ext/intl/tests/bug55562.phpt      2011-09-04 18:50:05 UTC (rev 316113)
> @@ -0,0 +1,13 @@
> +--TEST--
> +grapheme_substr() - Bug55562 - grapheme_substr() returns false if length parameter is to large
> +--SKIPIF--
> +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
> +--FILE--
> +<?php
> +var_dump(
> +  grapheme_substr('FOK', 1, 20), // expected: OK
> +  grapheme_substr('한국어', 1, 20) //expected: 국어
> +);
> +--EXPECT--
> +string(2) "OK"
> +string(6) "국어"
>
>
> --
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>



-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org


Thread (3 messages)

« previous php.cvs (#66180) next »