Skip to content

Commit

Permalink
Support non-ASCII characters in EuiSearchBar & Query (#1415)
Browse files Browse the repository at this point in the history
* wip

* Support for specifically extended character glyphs range

* changelog

* don't modify yarn.lock
  • Loading branch information
chandlerprall authored Jan 9, 2019
1 parent 7a4b53e commit 7ee0fc6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
- Updated `gisApp` icon ([#1413](https://github.com/elastic/eui/pull/1413))
- Added `isAutoRefreshOnly` prop to `EuiSuperDatePicker` ([#1412](https://github.com/elastic/eui/pull/1412))

**Bug fixes**

- Support extended characters (e.g. non-latin, unicode) in `EuiSearchBar` and `EuiQuery` ([#1415](https://github.com/elastic/eui/pull/1415))

## [`6.2.0`](https://github.com/elastic/eui/tree/v6.2.0)

- Added `logoCodesandbox` and updated `apmApp` icons ([#1407](https://github.com/elastic/eui/pull/1407))
Expand Down
10 changes: 10 additions & 0 deletions src/components/search_bar/query/default_syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ wordChar
= alnum
/ [-_*:]
/ escapedChar
/ extendedGlyph
// This isn't _strictly_ correct:
// for our purposes, a non-ascii word character is considered to
// be anything above \`Latin-1 Punctuation & Symbols\`, which ends at U+00BF
// This allows any non-ascii character, including the full set of unicode characters
// even those in the supplementary planes (U+010000 → U+10FFFF) as those will be seen individually
// in their surrogate pairs which are of the format /[\uD800-\uDBFF][\uDC00-\uDFFF]/
extendedGlyph
= [\u00C0-\uFFFF]
escapedChar
= "\\\\" reservedChar
Expand Down
22 changes: 22 additions & 0 deletions src/components/search_bar/query/default_syntax.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,28 @@ describe('defaultSyntax', () => {
expect(clause.value).toBe('dash-3');
});

test('unicode field and term values', () => {
const query = 'name:👸Queen_Elizabeth 🤴King_Henry';
const ast = defaultSyntax.parse(query);

expect(ast).toBeDefined();
expect(ast.clauses).toBeDefined();
expect(ast.clauses).toHaveLength(2);

let clause = ast.getSimpleFieldClause('name', '👸Queen_Elizabeth');
expect(clause).toBeDefined();
expect(AST.Field.isInstance(clause)).toBe(true);
expect(AST.Match.isMustClause(clause)).toBe(true);
expect(clause.field).toBe('name');
expect(clause.value).toBe('👸Queen_Elizabeth');

clause = ast.getTermClause('🤴King_Henry');
expect(clause).toBeDefined();
expect(AST.Term.isInstance(clause)).toBe(true);
expect(AST.Match.isMustClause(clause)).toBe(true);
expect(clause.value).toBe('🤴King_Henry');
});

test('escaped chars as default clauses', () => {
const query = '-\\: \\\\';
const ast = defaultSyntax.parse(query);
Expand Down

0 comments on commit 7ee0fc6

Please sign in to comment.