Program: 15793
Project: 15793
Buggy source:
/** 
 * Sets a setting by name and string value. In additional to the settings understood by  {@link Configurable#setSetting the super method}, it understands these: <ul> <li><code>"auto_import"</code>: Sets the list of auto-imports. Example of valid value: <br><code>/lib/form.ftl as f, /lib/widget as w, "/lib/evil name.ftl" as odd</code> See:   {@link #setAutoImports}<li><code>"auto_include"</code>: Sets the list of auto-includes. Example of valid value: <br><code>/include/common.ftl, "/include/evil name.ftl"</code> See:   {@link #setAutoIncludes}<li><code>"default_encoding"</code>: The name of the charset, such as <code>"UTF-8"</code>. See:   {@link #setDefaultEncoding}<li><code>"localized_lookup"</code>: <code>"true"</code>, <code>"false"</code>, <code>"yes"</code>, <code>"no"</code>, <code>"t"</code>, <code>"f"</code>, <code>"y"</code>, <code>"n"</code>. Case insensitive. See:   {@link #setLocalizedLookup}<li><code>"strict_syntax"</code>: <code>"true"</code>, <code>"false"</code>, etc. See:   {@link #setStrictSyntaxMode}<li><code>"whitespace_stripping"</code>: <code>"true"</code>, <code>"false"</code>, etc. See:   {@link #setWhitespaceStripping}<li><code>"cache_storage"</code>: If the value contains dot, then it is interpreted as class name, and the object will be created with its parameterless constructor. If the value does not contain dot, then a   {@link freemarker.cache.MruCacheStorage} will be used with themaximum strong and soft sizes specified with the setting value. Examples of valid setting values: <table border=1 cellpadding=4> <tr><th>Setting value<th>max. strong size<th>max. soft size <tr><td><code>"strong:50, soft:500"</code><td>50<td>500 <tr><td><code>"strong:100, soft"</code><td>100<td><code>Integer.MAX_VALUE</code> <tr><td><code>"strong:100"</code><td>100<td>0 <tr><td><code>"soft:100"</code><td>0<td>100 <tr><td><code>"strong"</code><td><code>Integer.MAX_VALUE</code><td>0 <tr><td><code>"soft"</code><td>0<td><code>Integer.MAX_VALUE</code> </table> The value is not case sensitive. The order of <tt>soft</tt> and <tt>strong</tt> entries is not significant. For more details see:  {@link #setCacheStorage}<li><code>"template_update_delay"</code>: Valid positive integer, the update delay measured in seconds. See:   {@link #setTemplateUpdateDelay}<li><code>"tag_syntax"</code>: Must be one of: <code>"auto_detect"</code>, <code>"angle_bracket"</code>, <code>"square_bracket"</code>. </ul>
 * @param key the name of the setting.
 * @param value the string that describes the new value of the setting.
 * @throws UnknownSettingException if the key is wrong.
 * @throws TemplateException if the new value of the setting can't be setfor any other reasons.
 */
public void setSetting(String key,String value) throws TemplateException {
  if ("String_Node_Str".equalsIgnoreCase(key)) {
    key=TEMPLATE_UPDATE_DELAY_KEY;
  }
 else   if ("String_Node_Str".equalsIgnoreCase(key)) {
    key=DEFAULT_ENCODING_KEY;
  }
  boolean callSuper=false;
  try {
    if (DEFAULT_ENCODING_KEY.equals(key)) {
      setDefaultEncoding(value);
    }
 else     if (LOCALIZED_LOOKUP_KEY.equals(key)) {
      setLocalizedLookup(StringUtil.getYesNo(value));
    }
 else     if (STRICT_SYNTAX_KEY.equals(key)) {
      setStrictSyntaxMode(StringUtil.getYesNo(value));
    }
 else     if (WHITESPACE_STRIPPING_KEY.equals(key)) {
      setWhitespaceStripping(StringUtil.getYesNo(value));
    }
 else     if (CACHE_STORAGE_KEY.equals(key)) {
      if (value.indexOf('.') == -1) {
        int strongSize=0;
        int softSize=0;
        Map map=StringUtil.parseNameValuePairList(value,String.valueOf(Integer.MAX_VALUE));
        Iterator it=map.entrySet().iterator();
        while (it.hasNext()) {
          Map.Entry ent=(Map.Entry)it.next();
          String pname=(String)ent.getKey();
          int pvalue;
          try {
            pvalue=Integer.parseInt((String)ent.getValue());
          }
 catch (          NumberFormatException e) {
            throw invalidSettingValueException(key,value);
          }
          if ("String_Node_Str".equalsIgnoreCase(pname)) {
            softSize=pvalue;
          }
 else           if ("String_Node_Str".equalsIgnoreCase(pname)) {
            strongSize=pvalue;
          }
 else {
            throw invalidSettingValueException(key,value);
          }
        }
        if (softSize == 0 && strongSize == 0) {
          throw invalidSettingValueException(key,value);
        }
        setCacheStorage(new MruCacheStorage(strongSize,softSize));
      }
 else {
        setCacheStorage((CacheStorage)ClassUtil.forName(value).newInstance());
      }
    }
 else     if (TEMPLATE_UPDATE_DELAY_KEY.equals(key)) {
      setTemplateUpdateDelay(Integer.parseInt(value));
    }
 else     if (AUTO_INCLUDE_KEY.equals(key)) {
      setAutoIncludes(parseAsList(value));
    }
 else     if (AUTO_IMPORT_KEY.equals(key)) {
      setAutoImports(parseAsImportList(value));
    }
 else     if (TAG_SYNTAX_KEY.equals(key)) {
      if ("String_Node_Str".equals(value)) {
        setTagSyntax(AUTO_DETECT_TAG_SYNTAX);
      }
 else       if ("String_Node_Str".equals(value)) {
        setTagSyntax(ANGLE_BRACKET_TAG_SYNTAX);
      }
 else       if ("String_Node_Str".equals(value)) {
        setTagSyntax(SQUARE_BRACKET_TAG_SYNTAX);
      }
 else {
        throw invalidSettingValueException(key,value);
      }
    }
 else {
      callSuper=true;
    }
  }
 catch (  Exception e) {
    throw new TemplateException("String_Node_Str" + StringUtil.jQuote(key) + "String_Node_Str"+ StringUtil.jQuote(value)+ "String_Node_Str",e,getEnvironment());
  }
  if (callSuper) {
    super.setSetting(key,value);
  }
}

Fixed version (ground truth):
/** 
 * Sets a setting by name and string value. In additional to the settings understood by  {@link Configurable#setSetting the super method}, it understands these: <ul> <li><code>"auto_import"</code>: Sets the list of auto-imports. Example of valid value: <br><code>/lib/form.ftl as f, /lib/widget as w, "/lib/evil name.ftl" as odd</code> See:   {@link #setAutoImports}<li><code>"auto_include"</code>: Sets the list of auto-includes. Example of valid value: <br><code>/include/common.ftl, "/include/evil name.ftl"</code> See:   {@link #setAutoIncludes}<li><code>"default_encoding"</code>: The name of the charset, such as <code>"UTF-8"</code>. See:   {@link #setDefaultEncoding}<li><code>"localized_lookup"</code>: <code>"true"</code>, <code>"false"</code>, <code>"yes"</code>, <code>"no"</code>, <code>"t"</code>, <code>"f"</code>, <code>"y"</code>, <code>"n"</code>. Case insensitive. See:   {@link #setLocalizedLookup}<li><code>"strict_syntax"</code>: <code>"true"</code>, <code>"false"</code>, etc. See:   {@link #setStrictSyntaxMode}<li><code>"whitespace_stripping"</code>: <code>"true"</code>, <code>"false"</code>, etc. See:   {@link #setWhitespaceStripping}<li><code>"cache_storage"</code>: If the value contains dot, then it is interpreted as class name, and the object will be created with its parameterless constructor. If the value does not contain dot, then a   {@link freemarker.cache.MruCacheStorage} will be used with themaximum strong and soft sizes specified with the setting value. Examples of valid setting values: <table border=1 cellpadding=4> <tr><th>Setting value<th>max. strong size<th>max. soft size <tr><td><code>"strong:50, soft:500"</code><td>50<td>500 <tr><td><code>"strong:100, soft"</code><td>100<td><code>Integer.MAX_VALUE</code> <tr><td><code>"strong:100"</code><td>100<td>0 <tr><td><code>"soft:100"</code><td>0<td>100 <tr><td><code>"strong"</code><td><code>Integer.MAX_VALUE</code><td>0 <tr><td><code>"soft"</code><td>0<td><code>Integer.MAX_VALUE</code> </table> The value is not case sensitive. The order of <tt>soft</tt> and <tt>strong</tt> entries is not significant. For more details see:  {@link #setCacheStorage}<li><code>"template_update_delay"</code>: Valid positive integer, the update delay measured in seconds. See:   {@link #setTemplateUpdateDelay}<li><code>"tag_syntax"</code>: Must be one of: <code>"auto_detect"</code>, <code>"angle_bracket"</code>, <code>"square_bracket"</code>. <li><code>"emulate_23_parser_bugs"</code>: must be <code>"false"</code> starting from FreeMarker 2.4.0. </ul>
 * @param key the name of the setting.
 * @param value the string that describes the new value of the setting.
 * @throws UnknownSettingException if the key is wrong.
 * @throws TemplateException if the new value of the setting can't be setfor any other reasons.
 */
public void setSetting(String key,String value) throws TemplateException {
  if ("String_Node_Str".equalsIgnoreCase(key)) {
    key=TEMPLATE_UPDATE_DELAY_KEY;
  }
 else   if ("String_Node_Str".equalsIgnoreCase(key)) {
    key=DEFAULT_ENCODING_KEY;
  }
  boolean callSuper=false;
  try {
    if (DEFAULT_ENCODING_KEY.equals(key)) {
      setDefaultEncoding(value);
    }
 else     if (LOCALIZED_LOOKUP_KEY.equals(key)) {
      setLocalizedLookup(StringUtil.getYesNo(value));
    }
 else     if (STRICT_SYNTAX_KEY.equals(key)) {
      setStrictSyntaxMode(StringUtil.getYesNo(value));
    }
 else     if (WHITESPACE_STRIPPING_KEY.equals(key)) {
      setWhitespaceStripping(StringUtil.getYesNo(value));
    }
 else     if (CACHE_STORAGE_KEY.equals(key)) {
      if (value.indexOf('.') == -1) {
        int strongSize=0;
        int softSize=0;
        Map map=StringUtil.parseNameValuePairList(value,String.valueOf(Integer.MAX_VALUE));
        Iterator it=map.entrySet().iterator();
        while (it.hasNext()) {
          Map.Entry ent=(Map.Entry)it.next();
          String pname=(String)ent.getKey();
          int pvalue;
          try {
            pvalue=Integer.parseInt((String)ent.getValue());
          }
 catch (          NumberFormatException e) {
            throw invalidSettingValueException(key,value);
          }
          if ("String_Node_Str".equalsIgnoreCase(pname)) {
            softSize=pvalue;
          }
 else           if ("String_Node_Str".equalsIgnoreCase(pname)) {
            strongSize=pvalue;
          }
 else {
            throw invalidSettingValueException(key,value);
          }
        }
        if (softSize == 0 && strongSize == 0) {
          throw invalidSettingValueException(key,value);
        }
        setCacheStorage(new MruCacheStorage(strongSize,softSize));
      }
 else {
        setCacheStorage((CacheStorage)ClassUtil.forName(value).newInstance());
      }
    }
 else     if (TEMPLATE_UPDATE_DELAY_KEY.equals(key)) {
      setTemplateUpdateDelay(Integer.parseInt(value));
    }
 else     if (AUTO_INCLUDE_KEY.equals(key)) {
      setAutoIncludes(parseAsList(value));
    }
 else     if (AUTO_IMPORT_KEY.equals(key)) {
      setAutoImports(parseAsImportList(value));
    }
 else     if (TAG_SYNTAX_KEY.equals(key)) {
      if ("String_Node_Str".equals(value)) {
        setTagSyntax(AUTO_DETECT_TAG_SYNTAX);
      }
 else       if ("String_Node_Str".equals(value)) {
        setTagSyntax(ANGLE_BRACKET_TAG_SYNTAX);
      }
 else       if ("String_Node_Str".equals(value)) {
        setTagSyntax(SQUARE_BRACKET_TAG_SYNTAX);
      }
 else {
        throw invalidSettingValueException(key,value);
      }
    }
 else     if (EMULATE_2_3_PARSER_BUGS.equals(key)) {
      setEmulate23ParserBugs(StringUtil.getYesNo(value));
    }
 else {
      callSuper=true;
    }
  }
 catch (  Exception e) {
    throw new TemplateException("String_Node_Str" + StringUtil.jQuote(key) + "String_Node_Str"+ StringUtil.jQuote(value)+ "String_Node_Str",e,getEnvironment());
  }
  if (callSuper) {
    super.setSetting(key,value);
  }
}