Skip to content

Forward-reverse grapheme mismatch on "\u{1F938}\u{1F3FE}\u{1F3FE}" #19

@Manishearth

Description

@Manishearth

Found by cargo-fuzz.

This crashes:


extern crate unicode_segmentation;

use unicode_segmentation::UnicodeSegmentation;
fn main() {
    let s = "\u{1F938}\u{1F3FE}\u{1F3FE}";
    let forward = UnicodeSegmentation::graphemes(s, true).collect::<Vec<_>>();
    let forward_reversed = forward.into_iter().rev().collect::<Vec<_>>();
    let reverse = UnicodeSegmentation::graphemes(s, true).rev().collect::<Vec<_>>();
    assert_eq!(forward_reversed, reverse);
}

It panics with (manually escaped):

left `["\u{1F938}\u{1F3FE}\u{1F3FE}"]`, right: `["\u{1F3FE}", "\u{1F938}\u{1F3FE}"]`

The original emoji is (uniview) U+1F938 PERSON DOING CARTWHEEL followed by two Fitzpatrick skin color modifiers. I suspect this error will happen whenever you have two skin color modifiers after a modifiable emoji.

cc @mbrubeck @kwantam

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions