Automattic / simplenote-ios

Simplenote for iOS
https://simplenote.com
GNU General Public License v2.0
2.04k stars 285 forks source link

Searching UTF-8 Characters "太陽", "平均", "赤道", "太", "均", etc. Cause App to Crash #1488

Open marcuswisecaesar opened 2 years ago

marcuswisecaesar commented 2 years ago


Usage environment: iOS 15.2.1 iPadOS 15.2.1 macOS Monterey 12.1 latest This bug is reproducible on iOS and macOS

Steps to reproduce the bug that causes the app to crash

  1. Copy the text content from this post - https://www.astroarts.co.jp/alacarte/kiso/kiso01-j.shtml - into a new note.

  2. search in Simplenote's search window with UTF-8 string Search keywords are "太陽", "平均", "赤道", "太", "均", etc.

These are the UTF-8 Codes: 592A 太 967D 陽 5E73 平 5747 均 8D64 赤 9053 道

Result: When the above memo is hit in the search result and displayed on the screen, the Simpenote application crashes. If there are multiple memos hit in the search results and the above memo is at the bottom, the app crashes when it is displayed by scrolling up.

What I expected: To be shown the search result for: "太陽" etc.

https://user-images.githubusercontent.com/36801460/152179462-e3ec0215-b671-4a5e-9f3a-8078c040f960.mov

dmsnell commented 2 years ago

Thanks for the report @marcuswisecaesar - I'm able to reliably reproduce the issue and I suspect we're cutting the post preview on a non-Unicode boundary since the note displays fine if not in the search.

cc: @jleandroperez

dmsnell commented 2 years ago

Noting a suspicious line:

https://github.com/Automattic/simplenote-ios/blob/67e8e6105f7e816d0b43fe89083d773ffdf565bf/Simplenote/Classes/Note%2BProperties.swift#L96-L97

We're using hard-coded string lengths and I'm wondering if those are cutting in between non-boundaries.

peril-automattic[bot] commented 1 year ago
Fails
:no_entry_sign: Please add a type label to this issue. e.g. '[Type] Enhancement'
:no_entry_sign: Please add a feature label to this issue. e.g. 'Stats'

Generated by :no_entry_sign: dangerJS

eshurakov commented 1 year ago

Most likely related to https://github.com/Automattic/simplenote-ios/pull/1064