Program: 77471
Project: 77471
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;
  String selectHandleTag=null;
  String url=validate(foreign.getHyperlinkAction());
  if (url != null) {
    if (enableMetadata) {
      selectHandleTag=HTMLTags.TAG_SPAN;
      writer.openTag(selectHandleTag);
      writer.attribute(HTMLTags.ATTR_CLASS,"String_Node_Str");
      setActiveIDTypeIID(foreign);
      setBookmark(selectHandleTag,foreign.getBookmark());
    }
    tagName=HTMLTags.TAG_A;
    outputAction(foreign.getHyperlinkAction(),url);
    setDisplayProperty(display,DISPLAY_BLOCK | DISPLAY_INLINE_BLOCK,styleBuffer);
    AttributeBuilder.checkHyperlinkTextDecoration(mergedStyle,styleBuffer);
  }
 else {
    if (enableMetadata) {
      selectHandleTag=getTagByType(display,DISPLAY_FLAG_ALL);
      writer.openTag(selectHandleTag);
      writer.attribute(HTMLTags.ATTR_CLASS,"String_Node_Str");
      setActiveIDTypeIID(foreign);
      setBookmark(selectHandleTag,foreign.getBookmark());
    }
    tagName=openTagByType(display,DISPLAY_FLAG_ALL);
    setDisplayProperty(display,DISPLAY_INLINE_BLOCK,styleBuffer);
  }
  setStyleName(foreign.getStyleClass());
  if (!enableMetadata) {
    outputBookmark(foreign,tagName);
  }
  writer.attribute(HTMLTags.ATTR_TITLE,foreign.getHelpText());
  handleShrink(display,mergedStyle,height,width,styleBuffer);
  handleStyle(foreign,styleBuffer,false);
  Object rawValue=foreign.getRawValue();
  String rawType=foreign.getRawType();
  boolean isHtml=IForeignContent.HTML_TYPE.equalsIgnoreCase(rawType);
  String text=rawValue == null ? null : rawValue.toString();
  if (isHtml) {
    Document doc=new TextParser().parse(text,TextParser.TEXT_TYPE_HTML);
    ReportDesignHandle design=(ReportDesignHandle)runnable.getDesignHandle();
    HTMLProcessor htmlProcessor=new HTMLProcessor(design);
    HashMap styleMap=new HashMap();
    Element body=null;
    if (doc != null) {
      NodeList bodys=doc.getElementsByTagName("String_Node_Str");
      if (bodys.getLength() > 0) {
        body=(Element)bodys.item(0);
      }
    }
    if (body != null) {
      htmlProcessor.execute(body,styleMap);
      processNodes(body,styleMap);
    }
  }
  writer.closeTag(tagName);
  if (enableMetadata) {
    writer.closeTag(selectHandleTag);
  }
}

Fixed version (ground truth):
public void startForeign(IForeignContent foreign){
  IStyle mergedStyle=foreign.getStyle();
  if (peek(mergedStyle)) {
    return;
  }
  logger.log(Level.FINE,"String_Node_Str");
  resizeTemplateElement(foreign);
  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;
  String selectHandleTag=null;
  String url=validate(foreign.getHyperlinkAction());
  if (url != null) {
    if (enableMetadata) {
      selectHandleTag=HTMLTags.TAG_SPAN;
      writer.openTag(selectHandleTag);
      writer.attribute(HTMLTags.ATTR_CLASS,"String_Node_Str");
      setActiveIDTypeIID(foreign);
      setBookmark(selectHandleTag,foreign.getBookmark());
    }
    tagName=HTMLTags.TAG_A;
    outputAction(foreign.getHyperlinkAction(),url);
    setDisplayProperty(display,DISPLAY_BLOCK | DISPLAY_INLINE_BLOCK,styleBuffer);
    AttributeBuilder.checkHyperlinkTextDecoration(mergedStyle,styleBuffer);
  }
 else {
    if (enableMetadata) {
      selectHandleTag=getTagByType(display,DISPLAY_FLAG_ALL);
      writer.openTag(selectHandleTag);
      writer.attribute(HTMLTags.ATTR_CLASS,"String_Node_Str");
      setActiveIDTypeIID(foreign);
      setBookmark(selectHandleTag,foreign.getBookmark());
    }
    tagName=openTagByType(display,DISPLAY_FLAG_ALL);
    setDisplayProperty(display,DISPLAY_INLINE_BLOCK,styleBuffer);
  }
  setStyleName(foreign.getStyleClass());
  if (!enableMetadata) {
    outputBookmark(foreign,tagName);
  }
  writer.attribute(HTMLTags.ATTR_TITLE,foreign.getHelpText());
  if (isTalbeTemplateElement(foreign)) {
    mergedStyle.setProperty(IStyle.STYLE_BORDER_TOP_STYLE,IStyle.DOTTED_VALUE);
    mergedStyle.setProperty(IStyle.STYLE_BORDER_BOTTOM_STYLE,IStyle.DOTTED_VALUE);
    mergedStyle.setProperty(IStyle.STYLE_BORDER_LEFT_STYLE,IStyle.DOTTED_VALUE);
    mergedStyle.setProperty(IStyle.STYLE_BORDER_RIGHT_STYLE,IStyle.DOTTED_VALUE);
    mergedStyle.setProperty(IStyle.STYLE_FONT_FAMILY,IStyle.SANS_SERIF_VALUE);
  }
  String textAlign=foreign.getComputedStyle().getTextAlign();
  if (textAlign != null) {
    styleBuffer.append("String_Node_Str");
    styleBuffer.append(textAlign);
    styleBuffer.append("String_Node_Str");
  }
  handleShrink(display,mergedStyle,height,width,styleBuffer);
  handleStyle(foreign,styleBuffer,false);
  String rawType=foreign.getRawType();
  boolean isHtml=IForeignContent.HTML_TYPE.equalsIgnoreCase(rawType);
  if (isHtml) {
    String verticalAlign=mergedStyle.getVerticalAlign();
    if (!"String_Node_Str".equals(verticalAlign) && height != null) {
      writer.openTag(HTMLTags.TAG_TABLE);
      writer.attribute(HTMLTags.ATTR_STYLE,"String_Node_Str");
      writer.openTag(HTMLTags.TAG_TR);
      writer.openTag(HTMLTags.TAG_TD);
      StringBuffer textStyleBuffer=new StringBuffer();
      textStyleBuffer.append("String_Node_Str");
      textStyleBuffer.append(verticalAlign);
      textStyleBuffer.append("String_Node_Str");
      writer.attribute(HTMLTags.ATTR_STYLE,textStyleBuffer);
      outputHtmlText(foreign);
      writer.closeTag(HTMLTags.TAG_TD);
      writer.closeTag(HTMLTags.TAG_TR);
      writer.closeTag(HTMLTags.TAG_TABLE);
    }
 else {
      outputHtmlText(foreign);
    }
  }
  writer.closeTag(tagName);
  if (enableMetadata) {
    writer.closeTag(selectHandleTag);
  }
}