Program: 47647
Project: 47647
Buggy source:
/** 
 * Reset the text for this page.
 * @param text
 */
private void setText(String text){
  lines=StringMethods.splitLines(text);
  level1Headers.clear();
  lineTypes=new ArrayList<KLineType>(lines.size());
  pageObjects.clear();
  Header dummyTopHeader=new Header(1,0,"String_Node_Str",null);
  level1Headers.add(dummyTopHeader);
  Header currentHeader=dummyTopHeader;
  int lineNum=0;
  boolean multiMarkdownMetadataSupport=pStore.getBoolean(MarkdownPreferencePage.PREF_MULTIMARKDOWN_METADATA);
  if (multiMarkdownMetadataSupport) {
    boolean validMetadata=true;
    for (lineNum=0; lineNum < lines.size(); lineNum++) {
      String line=lines.get(lineNum);
      if (Utils.isBlank(line)) {
        break;
      }
      Matcher m=multiMarkdownTag.matcher(line);
      if (!m.find()) {
        if (lineNum == 0) {
          validMetadata=false;
          break;
        }
 else         if (!line.matches("String_Node_Str")) {
          validMetadata=false;
          break;
        }
      }
    }
    if (validMetadata) {
      String data="String_Node_Str";
      String tag="String_Node_Str";
      for (lineNum=0; lineNum < lines.size(); lineNum++) {
        String line=lines.get(lineNum);
        if (Utils.isBlank(line)) {
          break;
        }
        Matcher m=multiMarkdownTag.matcher(line);
        if (!m.find()) {
          if (lineNum == 0) {
            break;
          }
          lineTypes.add(KLineType.META);
          data+=StrUtils.LINEEND + line.trim();
          multiMarkdownTags.put(tag,data);
        }
 else {
          lineTypes.add(KLineType.META);
          tag=m.group(0);
          data=m.group(1).trim();
          if (m.group(1).endsWith(line))           multiMarkdownTags.put(tag,data);
        }
      }
    }
 else {
      lineNum=0;
    }
  }
  for (; lineNum < lines.size(); lineNum++) {
    String line=lines.get(lineNum);
    int h=numHash(line);
    String hLine=line;
    int hLineNum=lineNum;
    int underline=-1;
    if (lineNum != 0) {
      underline=just(line,'=') ? 1 : just(line,'-') ? 2 : -1;
    }
    if (underline != -1) {
      h=underline;
      hLineNum=lineNum - 1;
      hLine=lines.get(lineNum - 1);
      lineTypes.set(hLineNum,KLineType.values()[h]);
      lineTypes.add(KLineType.MARKER);
    }
    if (h > 0) {
      if (underline == -1)       lineTypes.add(KLineType.values()[h]);
      Header header=new Header(h,hLineNum,hLine,currentHeader);
      if (h == 1) {
        level1Headers.add(header);
      }
      pageObjects.put(hLineNum,header);
      currentHeader=header;
      continue;
    }
    if (Utils.isBlank(line)) {
      lineTypes.add(KLineType.BLANK);
      continue;
    }
    lineTypes.add(KLineType.NORMAL);
  }
  if (dummyTopHeader.getSubHeaders().size() == 0) {
    level1Headers.remove(dummyTopHeader);
  }
  boolean githubSyntaxSupport=pStore.getBoolean(MarkdownPreferencePage.PREF_GITHUB_SYNTAX);
  if (githubSyntaxSupport) {
    boolean inCodeBlock=false;
    for (lineNum=0; lineNum < lines.size(); lineNum++) {
      String line=lines.get(lineNum);
      if (line.matches("String_Node_Str")) {
        inCodeBlock=!inCodeBlock;
        lines.set(lineNum,"String_Node_Str");
        lineTypes.set(lineNum,KLineType.NORMAL);
        continue;
      }
      if (inCodeBlock) {
        lines.set(lineNum,"String_Node_Str" + line);
      }
    }
    for (lineNum=0; lineNum < lines.size(); lineNum++) {
      String line=lines.get(lineNum);
      boolean urlReplaced;
      do {
        urlReplaced=false;
        Matcher m=githubURLDetection.matcher(line);
        while (m.find()) {
          if ((m.start() - 1 >= 0) && (m.end() < line.length()) && (line.charAt(m.start() - 1) == '<')&& (line.charAt(m.end()) == '>')) {
            continue;
          }
          if ((m.start() - 2 >= 0) && (m.end() < line.length()) && (line.charAt(m.start() - 2) == ']')&& (line.charAt(m.start() - 1) == '(')&& (line.charAt(m.end()) == ')')) {
            continue;
          }
          if ((m.start() - 2 >= 0) && (m.end() + 1 < line.length()) && (line.charAt(m.start() - 2) == ']')&& (line.charAt(m.start() - 1) == '(')&& (line.charAt(m.end()) == ' ')&& (line.charAt(m.end() + 1) == '"')) {
            continue;
          }
          if (m.start() - 1 >= 0) {
            line=line.substring(0,m.start()) + "String_Node_Str" + m.group(0)+ "String_Node_Str"+ line.substring(m.end());
          }
 else {
            line="String_Node_Str" + m.group(0) + "String_Node_Str"+ line.substring(m.end());
          }
          lines.set(lineNum,line);
          urlReplaced=true;
          break;
        }
      }
 while (urlReplaced);
    }
  }
}

Fixed version (ground truth):
/** 
 * Reset the text for this page.
 * @param text
 */
private void setText(String text){
  lines=StringMethods.splitLines(text);
  level1Headers.clear();
  lineTypes=new ArrayList<KLineType>(lines.size());
  pageObjects.clear();
  Header dummyTopHeader=new Header(1,0,"String_Node_Str",null);
  level1Headers.add(dummyTopHeader);
  Header currentHeader=dummyTopHeader;
  int lineNum=0;
  boolean multiMarkdownMetadataSupport=pStore.getBoolean(MarkdownPreferencePage.PREF_MULTIMARKDOWN_METADATA);
  if (multiMarkdownMetadataSupport) {
    boolean validMetadata=true;
    for (lineNum=0; lineNum < lines.size(); lineNum++) {
      String line=lines.get(lineNum);
      if (Utils.isBlank(line)) {
        break;
      }
      Matcher m=multiMarkdownTag.matcher(line);
      if (!m.find()) {
        if (lineNum == 0) {
          validMetadata=false;
          break;
        }
 else         if (!line.matches("String_Node_Str")) {
          validMetadata=false;
          break;
        }
      }
    }
    if (validMetadata) {
      String data="String_Node_Str";
      String tag="String_Node_Str";
      for (lineNum=0; lineNum < lines.size(); lineNum++) {
        String line=lines.get(lineNum);
        if (Utils.isBlank(line)) {
          break;
        }
        Matcher m=multiMarkdownTag.matcher(line);
        if (!m.find()) {
          if (lineNum == 0) {
            break;
          }
          lineTypes.add(KLineType.META);
          data+=StrUtils.LINEEND + line.trim();
          multiMarkdownTags.put(tag,data);
        }
 else {
          lineTypes.add(KLineType.META);
          tag=m.group(0);
          data=m.group(1).trim();
          if (m.group(1).endsWith(line))           multiMarkdownTags.put(tag,data);
        }
      }
    }
 else {
      lineNum=0;
    }
  }
  boolean githubSyntaxSupport=pStore.getBoolean(MarkdownPreferencePage.PREF_GITHUB_SYNTAX);
  boolean inCodeBlock=false;
  for (; lineNum < lines.size(); lineNum++) {
    String line=lines.get(lineNum);
    if (githubSyntaxSupport && line.startsWith("String_Node_Str")) {
      inCodeBlock=!inCodeBlock;
    }
    if (!inCodeBlock) {
      int h=numHash(line);
      String hLine=line;
      int hLineNum=lineNum;
      int underline=-1;
      if (lineNum != 0) {
        underline=just(line,'=') ? 1 : just(line,'-') ? 2 : -1;
      }
      if (underline != -1) {
        h=underline;
        hLineNum=lineNum - 1;
        hLine=lines.get(lineNum - 1);
        lineTypes.set(hLineNum,KLineType.values()[h]);
        lineTypes.add(KLineType.MARKER);
      }
      if (h > 0) {
        if (underline == -1)         lineTypes.add(KLineType.values()[h]);
        Header header=new Header(h,hLineNum,hLine,currentHeader);
        if (h == 1) {
          level1Headers.add(header);
        }
        pageObjects.put(hLineNum,header);
        currentHeader=header;
        continue;
      }
    }
    if (Utils.isBlank(line)) {
      lineTypes.add(KLineType.BLANK);
      continue;
    }
    lineTypes.add(KLineType.NORMAL);
  }
  if (dummyTopHeader.getSubHeaders().size() == 0) {
    level1Headers.remove(dummyTopHeader);
  }
  if (githubSyntaxSupport) {
    inCodeBlock=false;
    for (lineNum=0; lineNum < lines.size(); lineNum++) {
      String line=lines.get(lineNum);
      if (line.matches("String_Node_Str")) {
        inCodeBlock=!inCodeBlock;
        lines.set(lineNum,"String_Node_Str");
        lineTypes.set(lineNum,KLineType.NORMAL);
        continue;
      }
      if (inCodeBlock) {
        lines.set(lineNum,"String_Node_Str" + line);
      }
    }
    for (lineNum=0; lineNum < lines.size(); lineNum++) {
      String line=lines.get(lineNum);
      boolean urlReplaced;
      do {
        urlReplaced=false;
        Matcher m=githubURLDetection.matcher(line);
        while (m.find()) {
          if ((m.start() - 1 >= 0) && (m.end() < line.length()) && (line.charAt(m.start() - 1) == '<')&& (line.charAt(m.end()) == '>')) {
            continue;
          }
          if ((m.start() - 2 >= 0) && (m.end() < line.length()) && (line.charAt(m.start() - 2) == ']')&& (line.charAt(m.start() - 1) == '(')&& (line.charAt(m.end()) == ')')) {
            continue;
          }
          if ((m.start() - 2 >= 0) && (m.end() + 1 < line.length()) && (line.charAt(m.start() - 2) == ']')&& (line.charAt(m.start() - 1) == '(')&& (line.charAt(m.end()) == ' ')&& (line.charAt(m.end() + 1) == '"')) {
            continue;
          }
          if (m.start() - 1 >= 0) {
            line=line.substring(0,m.start()) + "String_Node_Str" + m.group(0)+ "String_Node_Str"+ line.substring(m.end());
          }
 else {
            line="String_Node_Str" + m.group(0) + "String_Node_Str"+ line.substring(m.end());
          }
          lines.set(lineNum,line);
          urlReplaced=true;
          break;
        }
      }
 while (urlReplaced);
    }
  }
}