wordpress-mobile / WordPress-Android

WordPress for Android

Home Page:http://android.wordpress.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StringIndexOutOfBoundsException: length=0; index=0

sentry-io opened this issue · comments

Sentry Issue: JETPACK-ANDROID-QWX

StringIndexOutOfBoundsException: length=0; index=0
    at org.wordpress.android.editor.AztecEditorFragment.parseContent(AztecEditorFragment.java:2283)
    at org.wordpress.android.editor.AztecEditorFragment.hasMediaItemsMarkedWithTag(AztecEditorFragment.java:2223)
    at org.wordpress.android.editor.AztecEditorFragment.hasMediaItemsMarkedUploading(AztecEditorFragment.java:2213)
    at org.wordpress.android.ui.posts.EditPostActivity$resetUploadingMediaToFailedIfPostHasNotMediaInProgressOrQueued$1.invoke(EditPostActivity.kt:1098)
    if ((!AztecEditorFragment.hasMediaItemsMarkedUploading(this@EditPostActivity, oldContent)
    at org.wordpress.android.ui.posts.EditPostActivity$resetUploadingMediaToFailedIfPostHasNotMediaInProgressOrQueued$1.invoke(EditPostActivity.kt:1096)
    editPostRepository.updateAsync({ postModel: PostModel ->
...
(25 additional frame(s) were not displayed)

Thanks for reporting! 👍

@antonis, I did some quick investigation here and it looks like there's a possibility that the CssStyleFormatter.getStyleAttribute(attributes, CssStyleFormatter.CSS_COLOR_ATTRIBUTE) evaluates to an empty string here in the Aztec code.

The problem is that a recent PR you worked on for Aztec (wordpress-mobile/AztecEditor-Android#1079) removed the check for isEmpty (https://github.com/wordpress-mobile/AztecEditor-Android/pull/1079/files#diff-b072035f2c70a485070535d72bcbd20b0fdbc44c3044bbb2fc8db4c8efa1929fL20) and this is causing a crash on Jetpack 24.7 (which is when the changes were picked by #20704).

I will assign this crash to you for further investigation if that's OK. Feel free to take a look and assign someone else if it makes more sense.

Btw, I think a possible fix is replacing the null check inside safelyParseColor with colorString.isNullOrEmpty

Thank you for the ping @thomashorta! Your investigation and suggested fix sounds reasonable to me.
I'm currently away from my computer and I would probably not be able to test and prepare a PR this week. If a fix is urgent please assign someone else on this.

@antonis I can help out as I am tasked with helping improve the crash free rate.

Thank you for covering for me @notandyvee 🙇