Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stories: Fix StringIndexOutOfBoundsException when below another block #13525

Merged
merged 1 commit into from
Dec 3, 2020

Conversation

aforcier
Copy link
Contributor

@aforcier aforcier commented Dec 3, 2020

Fixes Automattic/stories-android#615.

It turns out that the StringIndexOutOfBoundsException was happening when the Story block was not the first block in the post. The end of the first block in the post would be matched, causing the substring end index to be earlier than the start index.

Fixed by calculating the end of the Story block relative to its start.

To test:

  • Create a new post in Gutenberg
  • Add a block, e.g. a paragraph block
  • Below it, add a Story block, and add some slides
  • Exit the story editor and try to save the post
  • Confirm that the post is saved and there is no crash

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Fixes a StringIndexOutOfBoundsException when the Story block
is not the first block in the post. Previously the end of the
first block would be matched, causing the substring end index to
be earlier than the start index.
@aforcier aforcier added this to the 16.3 ❄️ milestone Dec 3, 2020
@aforcier aforcier requested a review from mzorz December 3, 2020 04:10
@peril-wordpress-mobile
Copy link

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link

You can test the changes on this Pull Request by downloading the APK here.

Copy link
Contributor

@mzorz mzorz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @aforcier ! Excellent, verified it works and yep, it makes sense 👍
LGTM :shipit:

@mzorz mzorz merged commit 430d39f into fix/stories-for-16.3 Dec 3, 2020
@mzorz mzorz deleted the fix/stories-stringindexoutofbounds branch December 3, 2020 13:06
@aforcier aforcier mentioned this pull request Dec 4, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants