Merge pull request #610 from RfidResearchGroup/fix_emoji_ps

Prevent emoji on ProxSpace
This commit is contained in:
Iceman 2020-03-16 18:21:58 +01:00 committed by GitHub
commit 063eeb2610
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1857 additions and 1855 deletions

File diff suppressed because it is too large Load diff

View file

@ -10,7 +10,11 @@ EMOJI_JSON_URL = 'https://raw.githubusercontent.com/github/gemoji/master/db/emoj
def print_emoji(emoji_json):
for alias in emoji_json['aliases']:
print(' {{":{0}:", "{1}"}},'.format(alias, emoji_json['emoji']))
print(' {{":{0}:", "{1}"}}, // {2}'.format(alias,
''.join('\\x{:02x}'.format(b) for b in emoji_json['emoji'].encode('utf8')),
emoji_json['emoji']))
print(
"""#ifndef EMOJIS_H__
@ -23,13 +27,12 @@ typedef struct emoji_s {
// emoji_t array are expected to be NULL terminated
static emoji_t EmojiTable[] = {""")
with urlopen(EMOJI_JSON_URL) as conn:
emojis_json = json.loads(conn.read().decode('utf-8'))
for emoji_json in emojis_json:
print_emoji(emoji_json)
print(
""" {NULL, NULL}
print(""" {NULL, NULL}
};
#endif""")

View file

@ -391,7 +391,7 @@ void memcpy_filter_ansi(void *dest, const void *src, size_t n, bool filter) {
static bool emojify_token(const char *token, uint8_t token_length, const char **emojified_token, uint8_t *emojified_token_length, emojiMode_t mode) {
int i = 0;
while (EmojiTable[i].alias) {
while (EmojiTable[i].alias && EmojiTable[i].emoji) {
if ((strlen(EmojiTable[i].alias) == token_length) && (0 == memcmp(EmojiTable[i].alias, token, token_length))) {
switch (mode) {
case EMOJI: {
@ -402,7 +402,7 @@ static bool emojify_token(const char *token, uint8_t token_length, const char **
case ALTTEXT: {
int j = 0;
*emojified_token_length = 0;
while (EmojiAltTable[j].alias) {
while (EmojiAltTable[j].alias && EmojiAltTable[i].alttext) {
if ((strlen(EmojiAltTable[j].alias) == token_length) && (0 == memcmp(EmojiAltTable[j].alias, token, token_length))) {
*emojified_token = EmojiAltTable[j].alttext;
*emojified_token_length = strlen(EmojiAltTable[j].alttext);