Program: 77678
Project: 77678
Buggy source:
/** 
 * Build URL for bookmark.
 * @param action
 * @param context
 * @return the bookmark url
 */
protected String buildBookmarkAction(IAction action,Object context){
  if (action == null || context == null)   return null;
  StringBuffer link=new StringBuffer();
  boolean realBookmark=false;
  if (this.document != null) {
    long pageNumber=this.document.getPageNumber(action.getBookmark());
    realBookmark=(pageNumber == this.page && !isEmbeddable);
  }
  String bookmark=action.getBookmark();
  try {
    bookmark=URLEncoder.encode(bookmark,ParameterAccessor.UTF_8_ENCODE);
  }
 catch (  UnsupportedEncodingException e) {
  }
  String baseURL=null;
  if (context instanceof HTMLRenderContext) {
    baseURL=((HTMLRenderContext)context).getBaseURL();
  }
  if (context instanceof PDFRenderContext) {
    baseURL=((PDFRenderContext)context).getBaseURL();
  }
  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=action.getReportName();
    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)));
  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,Object context){
  if (action == null || context == null)   return null;
  String baseURL=null;
  if (context instanceof HTMLRenderContext) {
    baseURL=((HTMLRenderContext)context).getBaseURL();
  }
  if (context instanceof PDFRenderContext) {
    baseURL=((PDFRenderContext)context).getBaseURL();
  }
  String bookmark=action.getBookmark();
  if (baseURL.lastIndexOf(IBirtConstants.SERVLET_PATH_FRAMESET) > 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=action.getReportName();
    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)));
  if (realBookmark) {
    link.append("String_Node_Str");
    link.append(bookmark);
  }
 else {
    link.append(ParameterAccessor.getQueryParameterString(ParameterAccessor.PARAM_BOOKMARK,bookmark));
  }
  return link.toString();
}