Program: 76432
Project: 76432
Buggy source:
/** 
 * Build URL for bookmark.
 * @param action
 * @param context
 * @return the bookmark url
 */
protected String buildBookmarkAction(IAction action,IReportContext context){
  if (action == null || context == null)   return null;
  String baseURL=null;
  Object renderContext=getRenderContext(context);
  if (renderContext instanceof HTMLRenderContext) {
    baseURL=((HTMLRenderContext)renderContext).getBaseURL();
  }
  if (renderContext instanceof PDFRenderContext) {
    baseURL=((PDFRenderContext)renderContext).getBaseURL();
  }
  if (baseURL == null)   return null;
  String bookmark=action.getBookmark();
  if (baseURL.lastIndexOf(IBirtConstants.SERVLET_PATH_FRAMESET) > 0 || baseURL.lastIndexOf(IBirtConstants.SERVLET_PATH_RUN) > 0) {
    return "String_Node_Str" + ParameterAccessor.htmlEncode(bookmark) + "String_Node_Str";
  }
  StringBuffer link=new StringBuffer();
  boolean realBookmark=false;
  if (this.document != null) {
    long pageNumber=this.document.getPageNumber(action.getBookmark());
    realBookmark=(pageNumber == this.page && !isEmbeddable);
  }
  try {
    bookmark=URLEncoder.encode(bookmark,ParameterAccessor.UTF_8_ENCODE);
  }
 catch (  UnsupportedEncodingException e) {
  }
  link.append(baseURL);
  link.append(ParameterAccessor.QUERY_CHAR);
  if (document != null) {
    link.append(ParameterAccessor.PARAM_REPORT_DOCUMENT);
    link.append(ParameterAccessor.EQUALS_OPERATOR);
    String documentName=document.getName();
    try {
      documentName=URLEncoder.encode(documentName,ParameterAccessor.UTF_8_ENCODE);
    }
 catch (    UnsupportedEncodingException e) {
    }
    link.append(documentName);
  }
 else   if (action.getReportName() != null && action.getReportName().length() > 0) {
    link.append(ParameterAccessor.PARAM_REPORT);
    link.append(ParameterAccessor.EQUALS_OPERATOR);
    String reportName=getReportName(context,action);
    try {
      reportName=URLEncoder.encode(reportName,ParameterAccessor.UTF_8_ENCODE);
    }
 catch (    UnsupportedEncodingException e) {
    }
    link.append(reportName);
  }
 else {
    return "String_Node_Str" + action.getActionString();
  }
  if (locale != null) {
    link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_LOCALE,locale.toString()));
  }
  if (isRtl) {
    link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_RTL,String.valueOf(isRtl)));
  }
  link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_MASTERPAGE,String.valueOf(this.isMasterPageContent)));
  try {
    if (resourceFolder != null)     resourceFolder=URLEncoder.encode(resourceFolder,ParameterAccessor.UTF_8_ENCODE);
  }
 catch (  UnsupportedEncodingException e) {
  }
  if (resourceFolder != null) {
    link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_RESOURCE_FOLDER,this.resourceFolder));
  }
  if (realBookmark) {
    link.append("String_Node_Str");
    link.append(bookmark);
  }
 else {
    link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_BOOKMARK,bookmark));
  }
  return link.toString();
}

Fixed version (ground truth):
/** 
 * Build URL for bookmark.
 * @param action
 * @param context
 * @return the bookmark url
 */
protected String buildBookmarkAction(IAction action,IReportContext context){
  if (action == null || context == null)   return null;
  String baseURL=null;
  Object renderContext=getRenderContext(context);
  if (renderContext instanceof HTMLRenderContext) {
    baseURL=((HTMLRenderContext)renderContext).getBaseURL();
  }
  if (renderContext instanceof PDFRenderContext) {
    baseURL=((PDFRenderContext)renderContext).getBaseURL();
  }
  if (baseURL == null)   return null;
  String bookmark=action.getBookmark();
  if (baseURL.lastIndexOf(IBirtConstants.SERVLET_PATH_FRAMESET) > 0) {
    return "String_Node_Str" + ParameterAccessor.htmlEncode(bookmark) + "String_Node_Str";
  }
 else   if (baseURL.lastIndexOf(IBirtConstants.SERVLET_PATH_RUN) > 0) {
    return "String_Node_Str" + bookmark + "String_Node_Str";
  }
  StringBuffer link=new StringBuffer();
  boolean realBookmark=false;
  if (this.document != null) {
    long pageNumber=this.document.getPageNumber(action.getBookmark());
    realBookmark=(pageNumber == this.page && !isEmbeddable);
  }
  try {
    bookmark=URLEncoder.encode(bookmark,ParameterAccessor.UTF_8_ENCODE);
  }
 catch (  UnsupportedEncodingException e) {
  }
  link.append(baseURL);
  link.append(ParameterAccessor.QUERY_CHAR);
  if (document != null) {
    link.append(ParameterAccessor.PARAM_REPORT_DOCUMENT);
    link.append(ParameterAccessor.EQUALS_OPERATOR);
    String documentName=document.getName();
    try {
      documentName=URLEncoder.encode(documentName,ParameterAccessor.UTF_8_ENCODE);
    }
 catch (    UnsupportedEncodingException e) {
    }
    link.append(documentName);
  }
 else   if (action.getReportName() != null && action.getReportName().length() > 0) {
    link.append(ParameterAccessor.PARAM_REPORT);
    link.append(ParameterAccessor.EQUALS_OPERATOR);
    String reportName=getReportName(context,action);
    try {
      reportName=URLEncoder.encode(reportName,ParameterAccessor.UTF_8_ENCODE);
    }
 catch (    UnsupportedEncodingException e) {
    }
    link.append(reportName);
  }
 else {
    return "String_Node_Str" + action.getActionString();
  }
  if (locale != null) {
    link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_LOCALE,locale.toString()));
  }
  if (isRtl) {
    link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_RTL,String.valueOf(isRtl)));
  }
  link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_MASTERPAGE,String.valueOf(this.isMasterPageContent)));
  try {
    if (resourceFolder != null)     resourceFolder=URLEncoder.encode(resourceFolder,ParameterAccessor.UTF_8_ENCODE);
  }
 catch (  UnsupportedEncodingException e) {
  }
  if (resourceFolder != null) {
    link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_RESOURCE_FOLDER,this.resourceFolder));
  }
  if (realBookmark) {
    link.append("String_Node_Str");
    link.append(bookmark);
  }
 else {
    link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_BOOKMARK,bookmark));
  }
  return link.toString();
}