Program: 15230
Project: 15230
Buggy source:
public boolean savePost(){
  EditText titleET=(EditText)findViewById(R.id.title);
  String title=titleET.getText().toString();
  WPEditText contentET=(WPEditText)findViewById(R.id.postContent);
  String content=EscapeUtils.unescapeHtml(WPHtml.toHtml(contentET.getText()));
  EditText passwordET=(EditText)findViewById(R.id.post_password);
  String password=passwordET.getText().toString();
  content=content.replace("String_Node_Str","String_Node_Str");
  content=content.replace("String_Node_Str","String_Node_Str");
  content=content.replace("String_Node_Str","String_Node_Str");
  TextView tvPubDate=(TextView)findViewById(R.id.pubDate);
  String pubDate=tvPubDate.getText().toString();
  long pubDateTimestamp=0;
  if (!pubDate.equals(getResources().getText(R.string.immediately))) {
    SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str");
    Date d=new Date();
    try {
      d=sdf.parse(pubDate);
      pubDateTimestamp=d.getTime();
    }
 catch (    ParseException e) {
      e.printStackTrace();
    }
catch (    java.text.ParseException e) {
      e.printStackTrace();
    }
  }
  String tags="String_Node_Str", postFormat="String_Node_Str";
  if (!isPage) {
    EditText tagsET=(EditText)findViewById(R.id.tags);
    tags=tagsET.getText().toString();
    Spinner postFormatSpinner=(Spinner)findViewById(R.id.postFormat);
    postFormat=postFormats[postFormatSpinner.getSelectedItemPosition()];
  }
  String images="String_Node_Str";
  boolean success=false;
  if (content.equals("String_Node_Str")) {
    AlertDialog.Builder dialogBuilder=new AlertDialog.Builder(EditPost.this);
    dialogBuilder.setTitle(getResources().getText(R.string.empty_fields));
    dialogBuilder.setMessage(getResources().getText(R.string.title_post_required));
    dialogBuilder.setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int whichButton){
      }
    }
);
    dialogBuilder.setCancelable(true);
    dialogBuilder.create().show();
  }
 else {
    if (!isNew) {
      post.deleteMediaFiles();
      Spannable s=contentET.getText();
      WPImageSpan[] click_spans=s.getSpans(0,s.length(),WPImageSpan.class);
      if (click_spans.length != 0) {
        for (int i=0; i < click_spans.length; i++) {
          WPImageSpan wpIS=click_spans[i];
          images+=wpIS.getImageSource().toString() + "String_Node_Str";
          MediaFile mf=new MediaFile();
          mf.setPostID(post.getId());
          mf.setTitle(wpIS.getTitle());
          mf.setCaption(wpIS.getCaption());
          mf.setDescription(wpIS.getDescription());
          mf.setFeatured(wpIS.isFeatured());
          mf.setFileName(wpIS.getImageSource().toString());
          mf.setHorizontalAlignment(wpIS.getHorizontalAlignment());
          mf.setWidth(wpIS.getWidth());
          mf.save(EditPost.this);
        }
      }
    }
    Spinner spinner=(Spinner)findViewById(R.id.status);
    int selectedStatus=spinner.getSelectedItemPosition();
    String status="String_Node_Str";
switch (selectedStatus) {
case 0:
      status="String_Node_Str";
    break;
case 1:
  status="String_Node_Str";
break;
case 2:
status="String_Node_Str";
break;
case 3:
status="String_Node_Str";
break;
case 4:
status="String_Node_Str";
break;
}
Double latitude=0.0;
Double longitude=0.0;
if (blog.isLocation()) {
try {
latitude=curLocation.getLatitude();
longitude=curLocation.getLongitude();
}
 catch (Exception e) {
e.printStackTrace();
}
}
String needle="String_Node_Str" + getResources().getText(R.string.more_tag) + "String_Node_Str";
if (isNew) {
post=new Post(id,title,content,images,pubDateTimestamp,categories.toString(),tags,status,password,latitude,longitude,isPage,postFormat,EditPost.this,true);
post.setLocalDraft(true);
if (content.indexOf(needle) >= 0) {
post.setDescription(content.substring(0,content.indexOf(needle)));
post.setMt_text_more(content.substring(content.indexOf(needle) + needle.length(),content.length()));
}
success=post.save();
post.deleteMediaFiles();
Spannable s=contentET.getText();
WPImageSpan[] click_spans=s.getSpans(0,s.length(),WPImageSpan.class);
if (click_spans.length != 0) {
for (int i=0; i < click_spans.length; i++) {
WPImageSpan wpIS=click_spans[i];
images+=wpIS.getImageSource().toString() + "String_Node_Str";
MediaFile mf=new MediaFile();
mf.setPostID(post.getId());
mf.setTitle(wpIS.getTitle());
mf.setCaption(wpIS.getCaption());
mf.setFileName(wpIS.getImageSource().toString());
mf.setFilePath(wpIS.getImageSource().toString());
mf.setHorizontalAlignment(wpIS.getHorizontalAlignment());
mf.setWidth(wpIS.getWidth());
mf.setVideo(wpIS.isVideo());
mf.save(EditPost.this);
}
}
}
 else {
post.setTitle(title);
if (content.indexOf(needle) >= 0) {
post.setDescription(content.substring(0,content.indexOf(needle)));
post.setMt_text_more(content.substring(content.indexOf(needle) + needle.length(),content.length()));
}
 else {
post.setDescription(content);
}
post.setMediaPaths(images);
post.setDate_created_gmt(pubDateTimestamp);
post.setCategories(categories);
post.setMt_keywords(tags);
post.setPost_status(status);
post.setWP_password(password);
post.setLatitude(latitude);
post.setLongitude(longitude);
post.setWP_post_form(postFormat);
success=post.update();
}
}
return success;
}

Fixed version (ground truth):
public boolean savePost(){
  EditText titleET=(EditText)findViewById(R.id.title);
  String title=titleET.getText().toString();
  WPEditText contentET=(WPEditText)findViewById(R.id.postContent);
  String content=EscapeUtils.unescapeHtml(WPHtml.toHtml(contentET.getText()));
  EditText passwordET=(EditText)findViewById(R.id.post_password);
  String password=passwordET.getText().toString();
  content=content.replace("String_Node_Str","String_Node_Str");
  content=content.replace("String_Node_Str","String_Node_Str");
  content=content.replace("String_Node_Str","String_Node_Str");
  TextView tvPubDate=(TextView)findViewById(R.id.pubDate);
  String pubDate=tvPubDate.getText().toString();
  long pubDateTimestamp=0;
  if (!pubDate.equals(getResources().getText(R.string.immediately))) {
    SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str");
    Date d=new Date();
    try {
      d=sdf.parse(pubDate);
      pubDateTimestamp=d.getTime();
    }
 catch (    ParseException e) {
      e.printStackTrace();
    }
catch (    java.text.ParseException e) {
      e.printStackTrace();
    }
  }
  String tags="String_Node_Str", postFormat="String_Node_Str";
  if (!isPage) {
    EditText tagsET=(EditText)findViewById(R.id.tags);
    tags=tagsET.getText().toString();
    Spinner postFormatSpinner=(Spinner)findViewById(R.id.postFormat);
    postFormat=postFormats[postFormatSpinner.getSelectedItemPosition()];
  }
  String images="String_Node_Str";
  boolean success=false;
  if (content.equals("String_Node_Str")) {
    AlertDialog.Builder dialogBuilder=new AlertDialog.Builder(EditPost.this);
    dialogBuilder.setTitle(getResources().getText(R.string.empty_fields));
    dialogBuilder.setMessage(getResources().getText(R.string.title_post_required));
    dialogBuilder.setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int whichButton){
      }
    }
);
    dialogBuilder.setCancelable(true);
    dialogBuilder.create().show();
  }
 else {
    if (!isNew) {
      post.deleteMediaFiles();
      Spannable s=contentET.getText();
      WPImageSpan[] click_spans=s.getSpans(0,s.length(),WPImageSpan.class);
      if (click_spans.length != 0) {
        for (int i=0; i < click_spans.length; i++) {
          WPImageSpan wpIS=click_spans[i];
          images+=wpIS.getImageSource().toString() + "String_Node_Str";
          MediaFile mf=new MediaFile();
          mf.setPostID(post.getId());
          mf.setTitle(wpIS.getTitle());
          mf.setCaption(wpIS.getCaption());
          mf.setDescription(wpIS.getDescription());
          mf.setFeatured(wpIS.isFeatured());
          mf.setFileName(wpIS.getImageSource().toString());
          mf.setHorizontalAlignment(wpIS.getHorizontalAlignment());
          mf.setWidth(wpIS.getWidth());
          mf.save(EditPost.this);
        }
      }
    }
    Spinner spinner=(Spinner)findViewById(R.id.status);
    int selectedStatus=spinner.getSelectedItemPosition();
    String status="String_Node_Str";
switch (selectedStatus) {
case 0:
      status="String_Node_Str";
    break;
case 1:
  status="String_Node_Str";
break;
case 2:
status="String_Node_Str";
break;
case 3:
status="String_Node_Str";
break;
case 4:
status="String_Node_Str";
break;
}
Double latitude=0.0;
Double longitude=0.0;
if (blog.isLocation()) {
try {
latitude=curLocation.getLatitude();
longitude=curLocation.getLongitude();
}
 catch (Exception e) {
e.printStackTrace();
}
}
String needle="String_Node_Str" + getResources().getText(R.string.more_tag) + "String_Node_Str";
if (isNew) {
post=new Post(id,title,content,images,pubDateTimestamp,categories.toString(),tags,status,password,latitude,longitude,isPage,postFormat,EditPost.this,true);
post.setLocalDraft(true);
if (content.indexOf(needle) >= 0) {
post.setDescription(content.substring(0,content.indexOf(needle)));
post.setMt_text_more(content.substring(content.indexOf(needle) + needle.length(),content.length()));
}
success=post.save();
post.deleteMediaFiles();
Spannable s=contentET.getText();
WPImageSpan[] image_spans=s.getSpans(0,s.length(),WPImageSpan.class);
if (image_spans.length != 0) {
for (int i=0; i < image_spans.length; i++) {
WPImageSpan wpIS=image_spans[i];
images+=wpIS.getImageSource().toString() + "String_Node_Str";
MediaFile mf=new MediaFile();
mf.setPostID(post.getId());
mf.setTitle(wpIS.getTitle());
mf.setCaption(wpIS.getCaption());
mf.setFileName(wpIS.getImageSource().toString());
mf.setFilePath(wpIS.getImageSource().toString());
mf.setHorizontalAlignment(wpIS.getHorizontalAlignment());
mf.setWidth(wpIS.getWidth());
mf.setVideo(wpIS.isVideo());
mf.save(EditPost.this);
}
}
}
 else {
post.setTitle(title);
if (content.indexOf(needle) >= 0) {
post.setDescription(content.substring(0,content.indexOf(needle)));
post.setMt_text_more(content.substring(content.indexOf(needle) + needle.length(),content.length()));
}
 else {
post.setDescription(content);
}
post.setMediaPaths(images);
post.setDate_created_gmt(pubDateTimestamp);
post.setCategories(categories);
post.setMt_keywords(tags);
post.setPost_status(status);
post.setWP_password(password);
post.setLatitude(latitude);
post.setLongitude(longitude);
post.setWP_post_form(postFormat);
success=post.update();
}
}
return success;
}