Program: 13640
Project: 13640
Buggy source:
/** 
 * Updates post object with content of this fragment
 */
public boolean updatePostContent(boolean isAutoSave) throws IllegalEditorStateException {
  if (mPost == null) {
    return false;
  }
  String title=StringUtils.notNullStr((String)mEditorFragment.getTitle());
  SpannableStringBuilder postContent;
  if (mEditorFragment.getSpannedContent() != null) {
    try {
      postContent=new SpannableStringBuilder(mEditorFragment.getSpannedContent());
    }
 catch (    RuntimeException e) {
      postContent=new SpannableStringBuilder(StringUtils.notNullStr((String)mEditorFragment.getContent()));
    }
  }
 else {
    postContent=new SpannableStringBuilder(StringUtils.notNullStr((String)mEditorFragment.getContent()));
  }
  String content;
  if (mPost.isLocalDraft()) {
    CharacterStyle[] characterStyles=postContent.getSpans(0,postContent.length(),CharacterStyle.class);
    for (    CharacterStyle characterStyle : characterStyles) {
      if (characterStyle instanceof SuggestionSpan) {
        postContent.removeSpan(characterStyle);
      }
    }
    content=WPHtml.toHtml(postContent);
    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");
    content=content.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
  }
 else {
    if (!isAutoSave) {
      MediaGalleryImageSpan[] gallerySpans=postContent.getSpans(0,postContent.length(),MediaGalleryImageSpan.class);
      for (      MediaGalleryImageSpan gallerySpan : gallerySpans) {
        int start=postContent.getSpanStart(gallerySpan);
        postContent.removeSpan(gallerySpan);
        postContent.insert(start,WPHtml.getGalleryShortcode(gallerySpan));
      }
    }
    WPImageSpan[] imageSpans=postContent.getSpans(0,postContent.length(),WPImageSpan.class);
    if (imageSpans.length != 0) {
      for (      WPImageSpan wpIS : imageSpans) {
        MediaFile mediaFile=wpIS.getMediaFile();
        if (mediaFile == null) {
          continue;
        }
        if (mediaFile.getMediaId() != null) {
          updateMediaFileOnServer(mediaFile);
        }
 else {
          mediaFile.setFileName(wpIS.getImageSource().toString());
          mediaFile.setFilePath(wpIS.getImageSource().toString());
        }
        int tagStart=postContent.getSpanStart(wpIS);
        if (!isAutoSave) {
          postContent.removeSpan(wpIS);
          if (mediaFile.getMediaId() != null && mediaFile.getMediaId().length() > 0) {
            postContent.insert(tagStart,WPHtml.getContent(wpIS));
          }
 else {
            postContent.insert(tagStart,"String_Node_Str" + wpIS.getImageSource().toString() + "String_Node_Str");
          }
        }
      }
    }
    content=postContent.toString();
  }
  boolean titleChanged=PostUtils.updatePostTitleIfDifferent(mPost,title);
  boolean contentChanged=PostUtils.updatePostContentIfDifferent(mPost,content);
  if (!mPost.isLocalDraft() && (titleChanged || contentChanged)) {
    mPost.setIsLocallyChanged(true);
  }
  return titleChanged || contentChanged;
}

Fixed version (ground truth):
/** 
 * Updates post object with content of this fragment
 */
public boolean updatePostContent(boolean isAutoSave) throws EditorFragmentNotAddedException {
  if (mPost == null) {
    return false;
  }
  String title=StringUtils.notNullStr((String)mEditorFragment.getTitle());
  SpannableStringBuilder postContent;
  if (mEditorFragment.getSpannedContent() != null) {
    try {
      postContent=new SpannableStringBuilder(mEditorFragment.getSpannedContent());
    }
 catch (    RuntimeException e) {
      postContent=new SpannableStringBuilder(StringUtils.notNullStr((String)mEditorFragment.getContent()));
    }
  }
 else {
    postContent=new SpannableStringBuilder(StringUtils.notNullStr((String)mEditorFragment.getContent()));
  }
  String content;
  if (mPost.isLocalDraft()) {
    CharacterStyle[] characterStyles=postContent.getSpans(0,postContent.length(),CharacterStyle.class);
    for (    CharacterStyle characterStyle : characterStyles) {
      if (characterStyle instanceof SuggestionSpan) {
        postContent.removeSpan(characterStyle);
      }
    }
    content=WPHtml.toHtml(postContent);
    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");
    content=content.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
  }
 else {
    if (!isAutoSave) {
      MediaGalleryImageSpan[] gallerySpans=postContent.getSpans(0,postContent.length(),MediaGalleryImageSpan.class);
      for (      MediaGalleryImageSpan gallerySpan : gallerySpans) {
        int start=postContent.getSpanStart(gallerySpan);
        postContent.removeSpan(gallerySpan);
        postContent.insert(start,WPHtml.getGalleryShortcode(gallerySpan));
      }
    }
    WPImageSpan[] imageSpans=postContent.getSpans(0,postContent.length(),WPImageSpan.class);
    if (imageSpans.length != 0) {
      for (      WPImageSpan wpIS : imageSpans) {
        MediaFile mediaFile=wpIS.getMediaFile();
        if (mediaFile == null) {
          continue;
        }
        if (mediaFile.getMediaId() != null) {
          updateMediaFileOnServer(mediaFile);
        }
 else {
          mediaFile.setFileName(wpIS.getImageSource().toString());
          mediaFile.setFilePath(wpIS.getImageSource().toString());
        }
        int tagStart=postContent.getSpanStart(wpIS);
        if (!isAutoSave) {
          postContent.removeSpan(wpIS);
          if (mediaFile.getMediaId() != null && mediaFile.getMediaId().length() > 0) {
            postContent.insert(tagStart,WPHtml.getContent(wpIS));
          }
 else {
            postContent.insert(tagStart,"String_Node_Str" + wpIS.getImageSource().toString() + "String_Node_Str");
          }
        }
      }
    }
    content=postContent.toString();
  }
  boolean titleChanged=PostUtils.updatePostTitleIfDifferent(mPost,title);
  boolean contentChanged=PostUtils.updatePostContentIfDifferent(mPost,content);
  if (!mPost.isLocalDraft() && (titleChanged || contentChanged)) {
    mPost.setIsLocallyChanged(true);
  }
  return titleChanged || contentChanged;
}