Program: 66525
Project: 66525
Buggy source:
/** 
 * builds URL for drillthrough action
 * @param action instance of the IAction instance
 * @param context the context for building the action string
 * @return a URL
 */
protected String buildDrillAction(IAction action,IReportContext context){
  if (action == null || context == null)   return null;
  String baseURL=getBaseUrl(context);
  StringBuffer link=new StringBuffer();
  String reportName=getReportName(context,action);
  if (reportName != null && !reportName.equals("String_Node_Str")) {
    link.append(baseURL);
    link.append(reportName.toLowerCase().endsWith("String_Node_Str") ? "String_Node_Str" : "String_Node_Str");
    try {
      link.append(URLEncoder.encode(reportName,ParameterAccessor.UTF_8_ENCODE));
    }
 catch (    UnsupportedEncodingException e1) {
    }
    String format=action.getFormat();
    if (format == null || format.length() == 0)     format=hostFormat;
    if (format != null && format.length() > 0) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_FORMAT,format));
    }
    if (action.getParameterBindings() != null) {
      Iterator paramsIte=action.getParameterBindings().entrySet().iterator();
      while (paramsIte.hasNext()) {
        Map.Entry entry=(Map.Entry)paramsIte.next();
        try {
          String key=(String)entry.getKey();
          Object valueObj=entry.getValue();
          if (valueObj != null) {
            if (valueObj instanceof List) {
              if (((List)valueObj).size() == 1) {
                valueObj=((List)valueObj).get(0);
              }
 else {
                valueObj=((List)valueObj).toArray();
              }
            }
            Object[] values;
            if (valueObj instanceof Object[]) {
              values=(Object[])valueObj;
            }
 else {
              values=new Object[1];
              values[0]=valueObj;
            }
            for (int i=0; i < values.length; i++) {
              String value=DataUtil.getDisplayValue(values[i],timeZone);
              if (value != null) {
                link.append(ParameterAccessor.getQueryParameterString(URLEncoder.encode(key,ParameterAccessor.UTF_8_ENCODE),URLEncoder.encode(value,ParameterAccessor.UTF_8_ENCODE)));
              }
 else {
                link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_ISNULL,URLEncoder.encode(key,ParameterAccessor.UTF_8_ENCODE)));
              }
            }
          }
        }
 catch (        UnsupportedEncodingException e) {
        }
      }
      if (!reportName.toLowerCase().endsWith(IBirtConstants.SUFFIX_REPORT_DOCUMENT) && baseURL.lastIndexOf(IBirtConstants.SERVLET_PATH_FRAMESET) > 0) {
        link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_OVERWRITE,String.valueOf(true)));
      }
    }
    if (locale != null) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_LOCALE,locale.toString()));
    }
    if (timeZone != null) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_TIMEZONE,timeZone.getID()));
    }
    if (isRtl) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_RTL,String.valueOf(isRtl)));
    }
    if (svg != null) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_SVG,String.valueOf(svg.booleanValue())));
    }
    if (isDesigner != null) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_DESIGNER,String.valueOf(isDesigner)));
    }
    if (pageOverflow != null) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_PAGE_OVERFLOW,pageOverflow));
    }
    link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_MASTERPAGE,String.valueOf(this.isMasterPageContent)));
    try {
      if (resourceFolder != null) {
        String res=URLEncoder.encode(resourceFolder,ParameterAccessor.UTF_8_ENCODE);
        link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_RESOURCE_FOLDER,res));
      }
    }
 catch (    UnsupportedEncodingException e) {
    }
    String bookmark=action.getBookmark();
    if (bookmark != null) {
      try {
        if (baseURL.lastIndexOf(IBirtConstants.SERVLET_PATH_PREVIEW) > 0 || IBirtConstants.PDF_RENDER_FORMAT.equalsIgnoreCase(format)) {
          if (!action.isBookmark() && reportName.toLowerCase().endsWith("String_Node_Str")) {
            InputOptions options=new InputOptions();
            options.setOption(InputOptions.OPT_LOCALE,locale);
            options.setOption(InputOptions.OPT_TIMEZONE,timeZone);
            bookmark=BirtReportServiceFactory.getReportService().findTocByName(reportName,bookmark,options);
          }
          if (bookmark != null) {
            link.append("String_Node_Str");
            link.append(URLEncoder.encode(bookmark,ParameterAccessor.UTF_8_ENCODE));
          }
        }
 else {
          bookmark=URLEncoder.encode(bookmark,ParameterAccessor.UTF_8_ENCODE);
          link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_BOOKMARK,bookmark));
          if (!action.isBookmark())           link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_ISTOC,"String_Node_Str"));
        }
      }
 catch (      UnsupportedEncodingException e) {
      }
    }
  }
  return link.toString();
}

Fixed version (ground truth):
/** 
 * builds URL for drillthrough action
 * @param action instance of the IAction instance
 * @param context the context for building the action string
 * @return a URL
 */
protected String buildDrillAction(IAction action,IReportContext context){
  if (action == null || context == null)   return null;
  String baseURL=getBaseUrl(context);
  StringBuffer link=new StringBuffer();
  String reportName=getReportName(context,action);
  if (reportName != null && !reportName.equals("String_Node_Str")) {
    link.append(baseURL);
    link.append(reportName.toLowerCase().endsWith("String_Node_Str") ? "String_Node_Str" : "String_Node_Str");
    try {
      link.append(URLEncoder.encode(reportName,ParameterAccessor.UTF_8_ENCODE));
    }
 catch (    UnsupportedEncodingException e1) {
    }
    String format=action.getFormat();
    if (format == null || format.length() == 0)     format=hostFormat;
    if (format != null && format.length() > 0) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_FORMAT,format));
    }
    if (action.getParameterBindings() != null) {
      Iterator paramsIte=action.getParameterBindings().entrySet().iterator();
      while (paramsIte.hasNext()) {
        Map.Entry entry=(Map.Entry)paramsIte.next();
        try {
          String key=(String)entry.getKey();
          Object valueObj=entry.getValue();
          if (valueObj != null) {
            if (valueObj instanceof List) {
              if (((List)valueObj).size() == 1) {
                valueObj=((List)valueObj).get(0);
              }
 else {
                valueObj=((List)valueObj).toArray();
              }
            }
            Object[] values;
            if (valueObj instanceof Object[]) {
              values=(Object[])valueObj;
            }
 else {
              values=new Object[1];
              values[0]=valueObj;
            }
            for (int i=0; i < values.length; i++) {
              String value=DataUtil.getDisplayValue(values[i],timeZone);
              if (value != null) {
                link.append(ParameterAccessor.getQueryParameterString(URLEncoder.encode(key,ParameterAccessor.UTF_8_ENCODE),URLEncoder.encode(value,ParameterAccessor.UTF_8_ENCODE)));
              }
 else {
                link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_ISNULL,URLEncoder.encode(key,ParameterAccessor.UTF_8_ENCODE)));
              }
            }
          }
        }
 catch (        UnsupportedEncodingException e) {
        }
      }
      if (!reportName.toLowerCase().endsWith(IBirtConstants.SUFFIX_REPORT_DOCUMENT) && baseURL.lastIndexOf(IBirtConstants.SERVLET_PATH_FRAMESET) > 0) {
        link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_OVERWRITE,String.valueOf(true)));
      }
    }
    if (locale != null) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_LOCALE,locale.toString()));
    }
    if (timeZone != null) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_TIMEZONE,timeZone.getID()));
    }
    if (isRtl) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_RTL,String.valueOf(isRtl)));
    }
    if (svg != null) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_SVG,String.valueOf(svg.booleanValue())));
    }
    if (isDesigner != null) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_DESIGNER,String.valueOf(isDesigner)));
    }
    if (pageOverflow > 0) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_PAGE_OVERFLOW,String.valueOf(pageOverflow)));
    }
    if (isMasterPageContent != null) {
      link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_MASTERPAGE,String.valueOf(isMasterPageContent)));
    }
    try {
      if (resourceFolder != null) {
        String res=URLEncoder.encode(resourceFolder,ParameterAccessor.UTF_8_ENCODE);
        link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_RESOURCE_FOLDER,res));
      }
    }
 catch (    UnsupportedEncodingException e) {
    }
    String bookmark=action.getBookmark();
    if (bookmark != null) {
      try {
        if (baseURL.lastIndexOf(IBirtConstants.SERVLET_PATH_PREVIEW) > 0 || IBirtConstants.PDF_RENDER_FORMAT.equalsIgnoreCase(format)) {
          if (!action.isBookmark() && reportName.toLowerCase().endsWith("String_Node_Str")) {
            InputOptions options=new InputOptions();
            options.setOption(InputOptions.OPT_LOCALE,locale);
            options.setOption(InputOptions.OPT_TIMEZONE,timeZone);
            bookmark=BirtReportServiceFactory.getReportService().findTocByName(reportName,bookmark,options);
          }
          if (bookmark != null) {
            link.append("String_Node_Str");
            link.append(URLEncoder.encode(bookmark,ParameterAccessor.UTF_8_ENCODE));
          }
        }
 else {
          bookmark=URLEncoder.encode(bookmark,ParameterAccessor.UTF_8_ENCODE);
          link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_BOOKMARK,bookmark));
          if (!action.isBookmark())           link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_ISTOC,"String_Node_Str"));
        }
      }
 catch (      UnsupportedEncodingException e) {
      }
    }
  }
  return link.toString();
}