diff --git a/backend/package.json b/backend/package.json index 2af223052..27a9df058 100644 --- a/backend/package.json +++ b/backend/package.json @@ -100,7 +100,8 @@ "slug": "~1.1.0", "trunc-html": "~1.1.2", "uuid": "~3.3.3", - "xregexp": "^4.2.4" + "xregexp": "^4.2.4", + "wait-on": "~3.3.0" }, "devDependencies": { "@babel/cli": "~7.5.5", diff --git a/backend/src/middleware/hashtags/extractHashtags.spec.js b/backend/src/middleware/hashtags/extractHashtags.spec.js index eb581d8f5..2e1761718 100644 --- a/backend/src/middleware/hashtags/extractHashtags.spec.js +++ b/backend/src/middleware/hashtags/extractHashtags.spec.js @@ -28,9 +28,14 @@ describe('extractHashtags', () => { }) it('ignores Hashtag links with not allowed character combinations', () => { + // Allowed are all unicode letters '\pL' and all digits '0-9'. There haveto be at least one letter in it. const content = - '
Something inspirational about #AbcDefXyz0123456789!*(),2, #0123456789, #0123456789a and #AbcDefXyz0123456789.
' - expect(extractHashtags(content)).toEqual(['0123456789a', 'AbcDefXyz0123456789']) + 'Something inspirational about #AbcDefXyz0123456789!*(),2, #0123456789, #0123456789a, #AbcDefXyz0123456789, and #λαπ.
' + expect(extractHashtags(content).sort()).toEqual([ + '0123456789a', + 'AbcDefXyz0123456789', + 'λαπ', + ]) }) }) diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql index e3ec9ad44..8207b5a97 100644 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql @@ -147,10 +147,10 @@ MATCH (c:Category {id: categoryId}) MERGE (p)-[:CATEGORIZED]->(c) WITH p, post.tags AS tags UNWIND tags AS tag -WITH '[^\\p{L}0-9]' as regexMatchAllNonUnicodeOrDigits -WITH apoc.text.replace(tag, regexMatchAllNonUnicodeOrDigits, '') as tagNoSpacesAllowed -WITH '^((\\p{L}+[\\p{L}0-9]*)|([0-9]+\\p{L}+[\\p{L}0-9]*))$' as regexHashtagMustNotIncludeOnlyDigits -CALL apoc.when(tagNoSpacesAllowed =~ regexHashtagMustNotIncludeOnlyDigits, 'RETURN tagNoSpacesAllowed', '', {tagNoSpacesAllowed: tagNoSpacesAllowed}) +WITH '[^\\p{L}0-9]' as regexMatchAllNonUnicodeLettersOrDigits +WITH apoc.text.replace(tag, regexMatchAllNonUnicodeLettersOrDigits, '') as tagNoSpacesAllowed +WITH '^((\\p{L}+[\\p{L}0-9]*)|([0-9]+\\p{L}+[\\p{L}0-9]*))$' as regexHashtagMustIncludeOnlyUnicodeLettersOrDigitsButNotOnlyDigits +CALL apoc.when(tagNoSpacesAllowed =~ regexHashtagMustIncludeOnlyUnicodeLettersOrDigitsButNotOnlyDigits, 'RETURN tagNoSpacesAllowed', '', {tagNoSpacesAllowed: tagNoSpacesAllowed}) YIELD value as validated WHERE validated.tagNoSpacesAllowed IS NOT NULL MERGE (t:Tag { id: validated.tagNoSpacesAllowed, disabled: false, deleted: false }) diff --git a/webapp/components/Editor/Editor.vue b/webapp/components/Editor/Editor.vue index 25080737a..75f550c2a 100644 --- a/webapp/components/Editor/Editor.vue +++ b/webapp/components/Editor/Editor.vue @@ -215,8 +215,9 @@ export default { }, sanitizeQuery(query) { if (this.suggestionType === HASHTAG) { - const regexMatchAllNonUnicodeOrDigits = build('[^\\pL0-9]') - query = replace(query, regexMatchAllNonUnicodeOrDigits, '', 'all') + // remove all non unicode letters and non digits + const regexMatchAllNonUnicodeLettersOrDigits = build('[^\\pL0-9]') + query = replace(query, regexMatchAllNonUnicodeLettersOrDigits, '', 'all') // if the query is only made of digits, make it empty return query.replace(/[0-9]/gm, '') === '' ? '' : query }