]> granicus.if.org Git - php/commitdiff
Emit a warning when an unsupported charset is requested in htmlentities.
authorWez Furlong <wez@php.net>
Thu, 26 Sep 2002 16:07:14 +0000 (16:07 +0000)
committerWez Furlong <wez@php.net>
Thu, 26 Sep 2002 16:07:14 +0000 (16:07 +0000)
Fixed #18521.

ext/standard/html.c

index d40c0c836a1240c3b38f58d39eedae2618beabf1..4a9e0cfc469883f3bfcd48e786ec7e177ca7fa4b 100644 (file)
@@ -521,7 +521,7 @@ inline static unsigned short get_next_char(enum entity_charset charset,
 /* {{{ entity_charset determine_charset
  * returns the charset identifier based on current locale or a hint.
  * defaults to iso-8859-1 */
-static enum entity_charset determine_charset(char *charset_hint)
+static enum entity_charset determine_charset(char *charset_hint TSRMLS_DC)
 {
        int i;
        enum entity_charset charset = cs_8859_1;
@@ -572,14 +572,22 @@ static enum entity_charset determine_charset(char *charset_hint)
 #endif
        }
        if (charset_hint)       {
-               if(!len) len = strlen(charset_hint);
+               int found = 0;
+               if (!len)
+                       len = strlen(charset_hint);
+               
                /* now walk the charset map and look for the codeset */
                for (i = 0; charset_map[i].codeset; i++)        {
                        if (strncasecmp(charset_hint, charset_map[i].codeset, len) == 0)        {
                                charset = charset_map[i].charset;
+                               found = 1;
                                break;
                        }
                }
+               if (!found) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "charset `%s' not supported, assuming iso-8859-1",
+                                       charset_hint);
+               }
        }
        return charset;
 }