Quick fix

Brad Fisher wrote:
> PHPAPI char* php_str_unhtmlentities(char *str, unsigned int *resultlen)

  PHPAPI char* php_str_unhtmlentities(char *str, unsigned int *resultlen 
TSRMLS_DC)


Use memcpy instead of strcpy/strncpy. strcpy() won't work when user uses
UCS-4 or like.

> 
> /* BF 6/11/01 ([EMAIL PROTECTED]) */
> /* {{{ proto string unhtmlentities(string str)
> 
>   Translates HTML entities in the given string into the appropriate
> characters.  This function is
>   the reverse of the standard PHP function htmlentities, however it DOES
> NOT currently use the same
>   translation table.  HTML entities have the form "&data;" where data is
> either the name of an
>   entity (ie. >, <, ") or a # symbol followed by a decimal
> value from 0 to 255 (ie. ", &#38)
> 
>   str       = the string to decode
> 
> */

proto cannot be that long, right? Anyone?

> PHP_FUNCTION(unhtmlentities)
> {
>         zval    **_str;         // The string

char *str;
uint strlen = 0;

>         uint    resultlen;
>         char    *result;
> 
>         int myargc = ZEND_NUM_ARGS();
>         if (myargc != 1 ||
>             zend_get_parameters_ex(myargc, &_str) == FAILURE)
>         {
>                 ZEND_WRONG_PARAM_COUNT();
>         } //if


if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &strlen) 
== FAILURE) {
    return;
}

> 
>         // Convert the parameters to the appropriate types
>         convert_to_string_ex(_str);
> 
>         resultlen = Z_STRLEN_PP(_str);
>         result = php_str_unhtmlentities(Z_STRVAL_PP(_str), &resultlen);

result = php_str_unhtmlentities(str, &strlen);


> 
>         // Return the result
>         RETURN_STRINGL(result, resultlen, 0);
> } // PHP_FUNCTION(unhtmlentities)
> /* }}} */
> 
> 
> 



-- 
Yasuo Ohgaki


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to