Program: 68221
Project: 68221
Buggy source:
/** 
 * Parse specified script, using correct expression instead of chart variables.
 * @param script
 * @param categoryExpr
 * @param seriesExpr
 * @param seriesName
 * @return
 */
private static String parseChartVariables(String script,String categoryExpr,String seriesExpr,String seriesName){
  if (script == null) {
    return null;
  }
  List<StringBuffer> symbols=new ArrayList<StringBuffer>();
  BufferedReader br=new BufferedReader(new StringReader(script));
  boolean isComments=false;
  boolean isCPlusCommnets=false;
  boolean isInQuotation=false;
  StringBuffer sb=new StringBuffer();
  String operations="String_Node_Str";
  try {
    int line=-1;
    do {
      String str=br.readLine();
      if (str == null) {
        break;
      }
      line++;
      if (line > 0) {
        sb.append('\n');
        sb=addToSymbolList(symbols,sb);
      }
      for (int i=0; i < str.length(); i++) {
        char c=str.charAt(i);
switch (c) {
case '+':
case '-':
case '!':
case '=':
case '<':
case '>':
case '&':
case '|':
case '(':
case ')':
          if (isCPlusCommnets || isComments) {
            sb.append(c);
          }
 else {
            sb=addToSymbolList(symbols,sb);
            sb.append(c);
          }
        break;
case '/':
      if (sb.length() == 0) {
        sb.append(c);
      }
 else       if (isComments && sb.charAt(sb.length() - 1) == '*') {
        isComments=false;
        sb.append(c);
        sb=addToSymbolList(symbols,sb);
      }
 else       if (isCPlusCommnets || isComments) {
        sb.append(c);
      }
 else       if (sb.charAt(sb.length() - 1) == '/') {
        isCPlusCommnets=true;
        sb.append(c);
      }
 else {
        sb=addToSymbolList(symbols,sb);
        sb.append(c);
      }
    break;
case '*':
  if (isCPlusCommnets || isComments) {
    sb.append(c);
  }
 else   if (sb.charAt(sb.length() - 1) == '/') {
    isComments=true;
    sb.append(c);
  }
 else {
    sb=addToSymbolList(symbols,sb);
    sb.append(c);
  }
break;
case '"':
case '\'':
if (isCPlusCommnets || isComments) {
sb.append(c);
}
 else {
sb.append(c);
if (!isInQuotation) {
  isInQuotation=true;
}
 else {
  isInQuotation=false;
  sb=addToSymbolList(symbols,sb);
}
}
break;
default :
if (!isComments && !isCPlusCommnets && !isInQuotation&& operations.indexOf(c) >= 0) {
sb=addToSymbolList(symbols,sb);
}
sb.append(c);
}
}
isCPlusCommnets=false;
isInQuotation=false;
sb=addToSymbolList(symbols,sb);
}
 while (true);
}
 catch (IOException e) {
return script;
}
StringBuffer returnSB=new StringBuffer();
for (StringBuffer s : symbols) {
String src=s.toString();
String expr=src.trim();
if (expr.equals(ScriptHandler.BASE_VALUE)) {
returnSB.append(src.replace(ScriptHandler.BASE_VALUE,categoryExpr == null ? "String_Node_Str" : categoryExpr));
}
 else if (expr.equals(ScriptHandler.ORTHOGONAL_VALUE)) {
returnSB.append(src.replace(ScriptHandler.ORTHOGONAL_VALUE,seriesExpr == null ? "String_Node_Str" : seriesExpr));
}
 else if (expr.equals(ScriptHandler.SERIES_VALUE)) {
StringBuffer ssb=new StringBuffer();
ssb.append("String_Node_Str");
ssb.append(seriesName);
ssb.append("String_Node_Str");
returnSB.append(src.replace(ScriptHandler.SERIES_VALUE,seriesName == null ? "String_Node_Str" : ssb));
}
 else {
returnSB.append(src);
}
}
return returnSB.toString();
}

Fixed version (ground truth):
/** 
 * Parse specified script, using correct expression instead of chart variables.
 * @param script
 * @param categoryExpr
 * @param seriesExpr
 * @param seriesName
 * @return
 */
private static String parseChartVariables(String script,String categoryExpr,String seriesExpr,String seriesName){
  if (script == null) {
    return null;
  }
  List<StringBuffer> symbols=new ArrayList<StringBuffer>();
  BufferedReader br=new BufferedReader(new StringReader(script));
  boolean isComments=false;
  boolean isCPlusCommnets=false;
  boolean isInQuotation=false;
  StringBuffer sb=new StringBuffer();
  try {
    int line=-1;
    do {
      String str=br.readLine();
      if (str == null) {
        break;
      }
      line++;
      if (line > 0) {
        sb.append('\n');
        sb=addToSymbolList(symbols,sb);
      }
      for (int i=0; i < str.length(); i++) {
        char c=str.charAt(i);
switch (c) {
case '+':
case '-':
case '!':
case '=':
case '<':
case '>':
case '&':
case '|':
case '(':
case ')':
          if (isCPlusCommnets || isComments) {
            sb.append(c);
          }
 else {
            sb=addToSymbolList(symbols,sb);
            sb.append(c);
          }
        break;
case '/':
      if (sb.length() == 0) {
        sb.append(c);
      }
 else       if (isComments && sb.charAt(sb.length() - 1) == '*') {
        isComments=false;
        sb.append(c);
        sb=addToSymbolList(symbols,sb);
      }
 else       if (isCPlusCommnets || isComments) {
        sb.append(c);
      }
 else       if (sb.charAt(sb.length() - 1) == '/') {
        isCPlusCommnets=true;
        sb.append(c);
      }
 else {
        sb=addToSymbolList(symbols,sb);
        sb.append(c);
      }
    break;
case '*':
  if (isCPlusCommnets || isComments) {
    sb.append(c);
  }
 else   if (sb.charAt(sb.length() - 1) == '/') {
    isComments=true;
    sb.append(c);
  }
 else {
    sb=addToSymbolList(symbols,sb);
    sb.append(c);
  }
break;
case '"':
case '\'':
if (isCPlusCommnets || isComments) {
sb.append(c);
}
 else {
sb.append(c);
if (!isInQuotation) {
  isInQuotation=true;
}
 else {
  isInQuotation=false;
  sb=addToSymbolList(symbols,sb);
}
}
break;
default :
if (!isComments && !isCPlusCommnets && !isInQuotation&& sb.length() > 0 && isOperator(sb.charAt(sb.length() - 1)) && !isOperator(c)) {
sb=addToSymbolList(symbols,sb);
}
sb.append(c);
}
}
isCPlusCommnets=false;
isInQuotation=false;
sb=addToSymbolList(symbols,sb);
}
 while (true);
}
 catch (IOException e) {
return script;
}
StringBuffer returnSB=new StringBuffer();
for (StringBuffer s : symbols) {
String src=s.toString();
String expr=src.trim();
if (expr.equals(ScriptHandler.BASE_VALUE)) {
returnSB.append(src.replace(ScriptHandler.BASE_VALUE,categoryExpr == null ? "String_Node_Str" : categoryExpr));
}
 else if (expr.equals(ScriptHandler.ORTHOGONAL_VALUE)) {
returnSB.append(src.replace(ScriptHandler.ORTHOGONAL_VALUE,seriesExpr == null ? "String_Node_Str" : seriesExpr));
}
 else if (expr.equals(ScriptHandler.SERIES_VALUE)) {
StringBuffer ssb=new StringBuffer();
ssb.append("String_Node_Str");
ssb.append(seriesName);
ssb.append("String_Node_Str");
returnSB.append(src.replace(ScriptHandler.SERIES_VALUE,seriesName == null ? "String_Node_Str" : ssb));
}
 else {
returnSB.append(src);
}
}
return returnSB.toString();
}