Mantis - Quercus
Viewing Issue Advanced Details
3314 minor always 02-02-09 08:17 02-02-09 20:34
tlandmann  
nam  
normal  
closed 3.2.1  
fixed  
none    
none 4.0.0  
0003314: html_entity_decode() not Unicode-compatible
The source code of the function is as follows:

--------------------

public static StringValue html_entity_decode(Env env,
                           StringValue string,
                           @Optional int quoteStyle,
                           @Optional String charset)
  {
    if (string.length() == 0)
      return env.getEmptyString();

    Iterator<Map.Entry<Value,Value>> iter;

    if (env.isUnicodeSemantics())
      iter = HTML_ENTITIES_ARRAY_UNICODE.getIterator(env); // LINE 380
    else
      iter = HTML_ENTITIES_ARRAY.getIterator(env);

    while (iter.hasNext()) {
      Map.Entry<Value,Value> entry = iter.next();
      StringValue key = entry.getKey().toStringValue();
      StringValue value = entry.getValue().toStringValue();

      string = RegexpModule.ereg_replace(env,
                                         value,
                                         key,
                                         string).toStringValue();
    }

    return string;
  }

--------------------

Line 380 (iter = HTML_ENTITIES_ARRAY_UNICODE.getIterator(env);) causes a NullPointerException because HTML_ENTITIES_ARRAY_UNICODE is not set.

Temporary workaround: Call htmlentities(" ") once right before using html_entity_decode() for the first time. This helps because htmlentities(), unlike html_entity_decode(), initializes the array if it still equals null (line 319).

However, I'd be happy if the problem could be fixed soon.

Notes
(0003797)
nam   
02-02-09 20:34   
At the moment, using unicode.semantics="true" is not recommended.

php/0jl0