mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
Merge pull request #8660 from atom/as-null-bytes-paired-char
Avoid pairing null byte characters
This commit is contained in:
commit
d6c0e8f8c8
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user