Program: 78939
Project: 78939
Buggy source:
public void startForeign(IForeignContent foreign){
  IStyle mergedStyle=foreign.getStyle();
  if (peek(mergedStyle)) {
    return;
  }
  logger.log(Level.FINE,"String_Node_Str");
  StringBuffer styleBuffer=new StringBuffer();
  DimensionType x=foreign.getX();
  DimensionType y=foreign.getY();
  DimensionType width=foreign.getWidth();
  DimensionType height=foreign.getHeight();
  int display;
  display=checkElementType(x,y,width,height,mergedStyle,styleBuffer);
  String tagName;
  if (handleAction(foreign.getHyperlinkAction())) {
    tagName=HTMLTags.TAG_A;
    setDisplayProperty(display,DISPLAY_BLOCK | DISPLAY_INLINE_BLOCK,styleBuffer);
    AttributeBuilder.checkHyperlinkTextDecoration(mergedStyle,styleBuffer);
  }
 else {
    tagName=openTagByType(display,DISPLAY_FLAG_ALL);
    setDisplayProperty(display,DISPLAY_INLINE_BLOCK,styleBuffer);
  }
  setStyleName(foreign.getStyleClass());
  setBookmark(tagName,foreign.getBookmark());
  writer.attribute(HTMLTags.ATTR_TITLE,foreign.getHelpText());
  handleShrink(display,mergedStyle,height,width,styleBuffer);
  handleStyle(foreign,styleBuffer);
  Object rawValue=foreign.getRawValue();
  String rawType=foreign.getRawType();
  boolean notHtml=!IForeignContent.HTML_TYPE.equalsIgnoreCase(rawType);
  String text=rawValue == null ? null : rawValue.toString();
  if (!notHtml) {
    text=text.trim();
    if (text.length() > 6) {
      String htmlTag=text.substring(0,6);
      if ("String_Node_Str".equalsIgnoreCase(htmlTag)) {
        text=text.substring(6);
      }
    }
    if (text.length() > 7) {
      String endTag=text.substring(text.length() - 7);
      if ("String_Node_Str".equalsIgnoreCase(endTag)) {
        text=text.substring(0,text.length() - 7);
      }
    }
  }
  writer.text(text,notHtml,notHtml);
  writer.closeTag(tagName);
}

Fixed version (ground truth):
public void startForeign(IForeignContent foreign){
  IStyle mergedStyle=foreign.getStyle();
  if (peek(mergedStyle)) {
    return;
  }
  logger.log(Level.FINE,"String_Node_Str");
  StringBuffer styleBuffer=new StringBuffer();
  DimensionType x=foreign.getX();
  DimensionType y=foreign.getY();
  DimensionType width=foreign.getWidth();
  DimensionType height=foreign.getHeight();
  int display;
  display=checkElementType(x,y,width,height,mergedStyle,styleBuffer);
  String tagName;
  if (handleAction(foreign.getHyperlinkAction())) {
    tagName=HTMLTags.TAG_A;
    setDisplayProperty(display,DISPLAY_BLOCK | DISPLAY_INLINE_BLOCK,styleBuffer);
    AttributeBuilder.checkHyperlinkTextDecoration(mergedStyle,styleBuffer);
  }
 else {
    tagName=openTagByType(display,DISPLAY_FLAG_ALL);
    setDisplayProperty(display,DISPLAY_INLINE_BLOCK,styleBuffer);
  }
  setStyleName(foreign.getStyleClass());
  setBookmark(tagName,foreign.getBookmark());
  writer.attribute(HTMLTags.ATTR_TITLE,foreign.getHelpText());
  handleShrink(display,mergedStyle,height,width,styleBuffer);
  handleStyle(foreign,styleBuffer);
  Object rawValue=foreign.getRawValue();
  String rawType=foreign.getRawType();
  boolean isHtml=IForeignContent.HTML_TYPE.equalsIgnoreCase(rawType);
  String text=rawValue == null ? null : rawValue.toString();
  if (isHtml) {
    text=text.replaceAll("String_Node_Str","String_Node_Str");
    text=text.replaceAll("String_Node_Str","String_Node_Str");
    text=text.replaceAll("String_Node_Str","String_Node_Str");
    text=text.replaceAll("String_Node_Str","String_Node_Str");
  }
  writer.text(text,!isHtml,!isHtml);
  writer.closeTag(tagName);
}