From d761ff34fed8259dd7fe8784898397bfc4a1c01e Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Thu, 15 Apr 2021 13:01:42 +0200 Subject: [PATCH 1/2] relaxing the HEADING_END definition a bit to allow finding it without an immediate newline postfix --- .../android/ui/stories/SaveStoryGutenbergBlockUseCase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stories/SaveStoryGutenbergBlockUseCase.kt b/WordPress/src/main/java/org/wordpress/android/ui/stories/SaveStoryGutenbergBlockUseCase.kt index dfa8c34ac584..824a8db077b0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stories/SaveStoryGutenbergBlockUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stories/SaveStoryGutenbergBlockUseCase.kt @@ -247,7 +247,7 @@ class SaveStoryGutenbergBlockUseCase @Inject constructor( companion object { const val TEMPORARY_ID_PREFIX = "tempid-" const val HEADING_START = "\n" + const val HEADING_END = " -->" const val DIV_PART = "
\n" const val CLOSING_TAG = "" } From fcfade1c2b8755ccf504a7a292eb22d0a7220de2 Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Thu, 15 Apr 2021 14:05:19 +0200 Subject: [PATCH 2/2] make sure to only relax the definiton of block start tag - end marker for search only --- .../android/ui/stories/SaveStoryGutenbergBlockUseCase.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stories/SaveStoryGutenbergBlockUseCase.kt b/WordPress/src/main/java/org/wordpress/android/ui/stories/SaveStoryGutenbergBlockUseCase.kt index 824a8db077b0..98199da1d2aa 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stories/SaveStoryGutenbergBlockUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stories/SaveStoryGutenbergBlockUseCase.kt @@ -108,7 +108,7 @@ class SaveStoryGutenbergBlockUseCase @Inject constructor( while (storyBlockStartIndex > -1 && storyBlockStartIndex < content.length) { storyBlockStartIndex = content.indexOf(HEADING_START, storyBlockStartIndex) if (storyBlockStartIndex > -1) { - val storyBlockEndIndex = content.indexOf(HEADING_END, storyBlockStartIndex) + val storyBlockEndIndex = content.indexOf(HEADING_END_NO_NEW_LINE, storyBlockStartIndex) try { val jsonString: String = content.substring( storyBlockStartIndex + HEADING_START.length, @@ -247,7 +247,8 @@ class SaveStoryGutenbergBlockUseCase @Inject constructor( companion object { const val TEMPORARY_ID_PREFIX = "tempid-" const val HEADING_START = "" + const val HEADING_END = " -->\n" + const val HEADING_END_NO_NEW_LINE = " -->" const val DIV_PART = "
\n" const val CLOSING_TAG = "" }