-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix an issue that deleting an emoji may crash the app #34508
Conversation
shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm
Outdated
Show resolved
Hide resolved
Kindly ping @jmagman for another look😀 |
options:kNilOptions | ||
range:charRange | ||
remainingRange:NULL]; | ||
if (gotCodePoint && u_hasBinaryProperty(codePoint, UCHAR_EMOJI)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this getting applied only to emoji?
Aren't there other multi-byte characters that are not emoji that we'd want to apply this to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From #34508 (comment), languages with diacritical marks will expect a backward deletion should only delete one part of the composed character, such as Thai and Hebrew.
We have two ways to distinguish this behavior from emoji's:
- check if the byte is a diacritical mark (and other properties I don't know yet)
- check if the byte is not in an emoji
I chose the second one to keep consistency with android (see FlutterTextUtils.getOffsetBefore)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh ok this makes sense.
@@ -7,6 +7,8 @@ | |||
#import <Foundation/Foundation.h> | |||
#import <UIKit/UIKit.h> | |||
|
|||
#include "unicode/uchar.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnfield since you jumped in, how do you feel about including this library? I've been trying to think of another way to check if it's an emoji without importing this but also reinventing the wheel. I guess it's okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine to me. This is what ICU is for and there's no getting around having ICU in a flutter app
argument = "--icu-data-file-path=Frameworks/Flutter.framework/icudtl.dat" | ||
isEnabled = "YES"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Without this the test will fail due to failing to load the ICU data file. Maybe we should file another issue to get rid of this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed flutter/flutter#108221
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine - in other tests we use the command line argument to load the ICU data file (see run_tests.py).
…ginTest.mm Co-authored-by: Jenn Magder <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the contribution and adding the backfilled tests!
@dnfield can you give the second hacker review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, as a hacker
* Fix an issue that deleting an emoji may crash the app (#34508) * Workaround iOS text input crash for emoji+Korean text (#36295) Co-authored-by: Yang Chao <[email protected]> Co-authored-by: Chris Yang <[email protected]>
An emoji may consist of two or more characters. We should make sure that deleting backward should remove the entire emoji.
Fixes flutter/flutter#106933
This issue was introduced in #32223
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.