mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Avoid pairing null bytes characters
This commit is contained in:
@@ -17,6 +17,9 @@ describe 'text utilities', ->
|
||||
expect(textUtils.hasPairedCharacter('\uFE0E\uFE0E')).toBe false
|
||||
expect(textUtils.hasPairedCharacter('\u0301\u0301')).toBe false
|
||||
|
||||
expect(textUtils.hasPairedCharacter('\0\u0301')).toBe false
|
||||
expect(textUtils.hasPairedCharacter('\0\uFE0E')).toBe false
|
||||
|
||||
describe '.isPairedCharacter(string, index)', ->
|
||||
it 'returns true when the index is the start of a high/low surrogate pair, variation sequence, or combined character', ->
|
||||
expect(textUtils.isPairedCharacter('a\uD835\uDF97b\uD835\uDF97c', 0)).toBe false
|
||||
@@ -44,3 +47,6 @@ describe 'text utilities', ->
|
||||
expect(textUtils.isPairedCharacter('ae\u0301c', 2)).toBe false
|
||||
expect(textUtils.isPairedCharacter('ae\u0301c', 3)).toBe false
|
||||
expect(textUtils.isPairedCharacter('ae\u0301c', 4)).toBe false
|
||||
|
||||
expect(textUtils.isPairedCharacter('\0\u0301c', 0)).toBe false
|
||||
expect(textUtils.isPairedCharacter('\0\uFE0E', 0)).toBe false
|
||||
|
||||
@@ -30,6 +30,7 @@ isSurrogatePair = (charCodeA, charCodeB) ->
|
||||
#
|
||||
# Return a {Boolean}.
|
||||
isVariationSequence = (charCodeA, charCodeB) ->
|
||||
return false if charCodeA is 0
|
||||
not isVariationSelector(charCodeA) and isVariationSelector(charCodeB)
|
||||
|
||||
# Are the given character codes a combined character pair?
|
||||
@@ -39,6 +40,7 @@ isVariationSequence = (charCodeA, charCodeB) ->
|
||||
#
|
||||
# Return a {Boolean}.
|
||||
isCombinedCharacter = (charCodeA, charCodeB) ->
|
||||
return false if charCodeA is 0
|
||||
not isCombiningCharacter(charCodeA) and isCombiningCharacter(charCodeB)
|
||||
|
||||
# Is the character at the given index the start of high/low surrogate pair
|
||||
|
||||
Reference in New Issue
Block a user