Automattic / simplenote-ios

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

Crash when searching for notes with keywords "poe" or "poE" #1403

Open reginabally opened 3 years ago

reginabally commented 3 years ago

The user reported in 4228972-zd-woothemes for crashes that happened on the iOS app when they performed a search using keywords "poe" or "poE". The crash happened when they tried different variations of the "e" characters like é.

Expected

It was expected that the app doesn't crash when searching for notes.

Observed

(Based on the details shared by the user since we're not able to reproduce this)

When I type "p","o", then "e" in the search box, the app clashes.
"p","o", then "E", it clashes too.
"p","o", then other every characters, it does not clash.

Reproduced

  1. On the app's search box at the top, type "p", "o", and then "e".
  2. The app crashed and returned to the device's home screen.

The user's screen recording with testing using different keyword variations can be downloaded in the ticket.

Make Model iOS Version App Version
iPhone iPhone 11 14.7.1 4.41

Note: The user's device language is in Japanese.

charliescheer commented 3 years ago

I took a look into this but could not replicate the issue. I suspect that the issue may be caused by the mix character types in their notes. From the video in the ticket most of their notes appear to be of mixed character types. I wonder if we could replicate this issue if we had a sample. @reginabally could we ask them to give us a copy of the entire text from a note on their device that would satisfy the search query "poe" It is likely that one of their notes has this character set in it and I suspect that is the one causing the issue.

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

Generated by :no_entry_sign: dangerJS

mdrockwell commented 3 years ago

@charliescheer They've shared the notes in their most recent reply: 4228972-zd-woothemes

Setting the ticket on-hold for a bit.

charliescheer commented 3 years ago

I took a look at this today, I don't have a solution yet, and suspect this may take a bit of time to solve. @mdrockwell The problem is a specific note that the user shared the one that starts with Los Angeles lɔːsǽndʒləs If they remove that note from their account they will be able to search again. I know this is not an ideal solution but for the time being that is probably the best way to go. The issue is with how swift breaks apart strings by words. My suspicion is that it does not like breaking the string apart by words using different languages at the same time, but I'm not 100% on that.

For my own reference, the issue is being caused by the EnumerateOption .byWords

enumerateSubstrings(in: range, options: [.localized, .byWords, .substringNotRequired]) { (_, wordRange, _, stop) in

If you remove the .byWords option the crash does not happen.

msilbers commented 3 years ago

The problem is a specific note that the user shared the one that starts with Los Angeles lɔːsǽndʒləs If they remove that note from their account they will be able to search again.

They have done this and it did indeed allow them to search