Program: 3669
Project: 3669
Buggy source:
/** 
 * Set relevant DC fields in an item from name values in the form. Some fields are repeatable in the form.  If this is the case, and the field is "contributor.author", the names in the request will be from the fields as follows: contributor_author_last_0       -> last name of first author contributor_author_first_0      -> first name(s) of first author contributor_author_last_1       -> last name of second author contributor_author_first_1      -> first name(s) of second author and so on.  If the field is unqualified: contributor_last_0        -> last name of first contributor contributor_first_0       -> first name(s) of first contributor If the parameter "submit_contributor_author_remove_n" is set, that value is removed. Otherwise the parameters are of the form: contributor_author_last contributor_author_first The values will be put in separate DCValues, in the form "last name, first name(s)", ordered as they appear in the list. These will replace any existing values.
 * @param request    the request object
 * @param item       the item to update
 * @param element    the DC element
 * @param qualifier  the DC qualifier, or null if unqualified
 * @param repeated   set to true if the field is repeatable on the form
 */
private void readNames(HttpServletRequest request,Item item,String element,String qualifier,boolean repeated){
  String dcname=element;
  if (qualifier != null) {
    dcname=element + "String_Node_Str" + qualifier;
  }
  List firsts=new LinkedList();
  List lasts=new LinkedList();
  if (repeated) {
    firsts=getRepeatedParameter(request,dcname + "String_Node_Str");
    lasts=getRepeatedParameter(request,dcname + "String_Node_Str");
    String buttonPressed=UIUtil.getSubmitButton(request,"String_Node_Str");
    String removeButton="String_Node_Str" + dcname + "String_Node_Str";
    if (buttonPressed.startsWith(removeButton)) {
      int valToRemove=Integer.parseInt(buttonPressed.substring(removeButton.length()));
      firsts.remove(valToRemove);
      lasts.remove(valToRemove);
    }
  }
 else {
    String lastName=request.getParameter(dcname + "String_Node_Str");
    String firstNames=request.getParameter(dcname + "String_Node_Str");
    if (lastName != null && !lastName.equals("String_Node_Str")) {
      lasts.add(lastName);
      firsts.add(firstNames);
    }
  }
  item.clearDC(element,qualifier,Item.ANY);
  for (int i=0; i < lasts.size(); i++) {
    String f=((String)firsts.get(i)).trim();
    String l=((String)lasts.get(i)).trim();
    int comma=l.indexOf(',');
    if (comma >= 0) {
      f=f + l.substring(comma + 1);
      l=l.substring(0,comma);
      while (f.startsWith("String_Node_Str")) {
        f=f.substring(1);
      }
    }
    item.addDC(element,qualifier,null,new DCPersonName(l,f).toString());
  }
}

Fixed version (ground truth):
/** 
 * Set relevant DC fields in an item from name values in the form. Some fields are repeatable in the form.  If this is the case, and the field is "contributor.author", the names in the request will be from the fields as follows: contributor_author_last_0       -> last name of first author contributor_author_first_0      -> first name(s) of first author contributor_author_last_1       -> last name of second author contributor_author_first_1      -> first name(s) of second author and so on.  If the field is unqualified: contributor_last_0        -> last name of first contributor contributor_first_0       -> first name(s) of first contributor If the parameter "submit_contributor_author_remove_n" is set, that value is removed. Otherwise the parameters are of the form: contributor_author_last contributor_author_first The values will be put in separate DCValues, in the form "last name, first name(s)", ordered as they appear in the list. These will replace any existing values.
 * @param request    the request object
 * @param item       the item to update
 * @param element    the DC element
 * @param qualifier  the DC qualifier, or null if unqualified
 * @param repeated   set to true if the field is repeatable on the form
 */
private void readNames(HttpServletRequest request,Item item,String element,String qualifier,boolean repeated){
  String dcname=element;
  if (qualifier != null) {
    dcname=element + "String_Node_Str" + qualifier;
  }
  List firsts=new LinkedList();
  List lasts=new LinkedList();
  if (repeated) {
    firsts=getRepeatedParameter(request,dcname + "String_Node_Str");
    lasts=getRepeatedParameter(request,dcname + "String_Node_Str");
    String buttonPressed=UIUtil.getSubmitButton(request,"String_Node_Str");
    String removeButton="String_Node_Str" + dcname + "String_Node_Str";
    if (buttonPressed.startsWith(removeButton)) {
      int valToRemove=Integer.parseInt(buttonPressed.substring(removeButton.length()));
      firsts.remove(valToRemove);
      lasts.remove(valToRemove);
    }
  }
 else {
    String lastName=request.getParameter(dcname + "String_Node_Str");
    String firstNames=request.getParameter(dcname + "String_Node_Str");
    lasts.add(lastName);
    firsts.add(firstNames);
  }
  item.clearDC(element,qualifier,Item.ANY);
  for (int i=0; i < lasts.size(); i++) {
    String f=(String)firsts.get(i);
    String l=(String)lasts.get(i);
    if (l != null && !((l.trim()).equals("String_Node_Str"))) {
      if (f == null) {
        f="String_Node_Str";
      }
      int comma=l.indexOf(',');
      if (comma >= 0) {
        f=f + l.substring(comma + 1);
        l=l.substring(0,comma);
        while (f.startsWith("String_Node_Str")) {
          f=f.substring(1);
        }
      }
      item.addDC(element,qualifier,null,new DCPersonName(l,f).toString());
    }
  }
}