From fd457e3c3ca294293891ff1671fd91b7b4b06e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 4 Sep 2019 13:51:23 +0200 Subject: [PATCH 1/4] Refactor backend test to test some unicode letters are excepted --- backend/src/middleware/hashtags/extractHashtags.spec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/middleware/hashtags/extractHashtags.spec.js b/backend/src/middleware/hashtags/extractHashtags.spec.js index eb581d8f5..3c986b3b6 100644 --- a/backend/src/middleware/hashtags/extractHashtags.spec.js +++ b/backend/src/middleware/hashtags/extractHashtags.spec.js @@ -28,9 +28,10 @@ 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', 'λαπ']) }) }) @@ -54,4 +55,4 @@ describe('extractHashtags', () => { }) }) }) -}) +}) \ No newline at end of file From 0a86cb6c4d5da7f1ed76f627b0f6e4697d87f5f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 4 Sep 2019 14:01:28 +0200 Subject: [PATCH 2/4] Merge branch '1395-hashtags-imported-with-not-allowed-chars' of https://github.com/Human-Connection/Human-Connection into 1395-hashtags-imported-with-not-allowed-chars --- .../hashtags/extractHashtags.spec.js | 8 ++++++-- backend/yarn.lock | 20 ++----------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/backend/src/middleware/hashtags/extractHashtags.spec.js b/backend/src/middleware/hashtags/extractHashtags.spec.js index 3c986b3b6..2e1761718 100644 --- a/backend/src/middleware/hashtags/extractHashtags.spec.js +++ b/backend/src/middleware/hashtags/extractHashtags.spec.js @@ -31,7 +31,11 @@ describe('extractHashtags', () => { // 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, #AbcDefXyz0123456789, and #λαπ.

' - expect(extractHashtags(content).sort()).toEqual(['0123456789a', 'AbcDefXyz0123456789', 'λαπ']) + expect(extractHashtags(content).sort()).toEqual([ + '0123456789a', + 'AbcDefXyz0123456789', + 'λαπ', + ]) }) }) @@ -55,4 +59,4 @@ describe('extractHashtags', () => { }) }) }) -}) \ No newline at end of file +}) diff --git a/backend/yarn.lock b/backend/yarn.lock index 2829dc9d0..2ac69e7b3 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -752,7 +752,7 @@ resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-8.2.1.tgz#924af04cbb22e17359c620d2a9c946e63f58eb77" integrity sha512-JPiBy+oSmsq3St7XlipfN5pNA6bDJ1kpa73PrK/zR29CVClDVqy04AanM/M/qx5bSF+I61DdCfAvRrujau+zRg== -"@hapi/joi@^15.0.3", "@hapi/joi@^15.1.0", "@hapi/joi@^15.1.1": +"@hapi/joi@^15.1.0", "@hapi/joi@^15.1.1": version "15.1.1" resolved "https://registry.yarnpkg.com/@hapi/joi/-/joi-15.1.1.tgz#c675b8a71296f02833f8d6d243b34c57b8ce19d7" integrity sha512-entf8ZMOK8sc+8YfeOlM8pCfg3b5+WZIKBfUaaJT8UsjAAPjartzxIYm3TIbjvA4u+u++KbcXD38k682nVHDAQ== @@ -7311,7 +7311,7 @@ request-promise-native@^1.0.5: stealthy-require "^1.1.1" tough-cookie "^2.3.3" -request@^2.61.0, request@^2.87.0, request@^2.88.0, request@~2.88.0: +request@^2.61.0, request@^2.87.0, request@~2.88.0: version "2.88.0" resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg== @@ -7447,11 +7447,6 @@ run-async@^2.2.0: dependencies: is-promise "^2.1.0" -rx@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" - integrity sha1-pfE/957zt0D+MKqAP7CfmIBdR4I= - rxjs@^6.4.0: version "6.5.2" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.2.tgz#2e35ce815cd46d84d02a209fb4e5921e051dbec7" @@ -8669,17 +8664,6 @@ w3c-hr-time@^1.0.1: dependencies: browser-process-hrtime "^0.1.2" -wait-on@~3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/wait-on/-/wait-on-3.3.0.tgz#9940981d047a72a9544a97b8b5fca45b2170a082" - integrity sha512-97dEuUapx4+Y12aknWZn7D25kkjMk16PbWoYzpSdA8bYpVfS6hpl2a2pOWZ3c+Tyt3/i4/pglyZctG3J4V1hWQ== - dependencies: - "@hapi/joi" "^15.0.3" - core-js "^2.6.5" - minimist "^1.2.0" - request "^2.88.0" - rx "^4.1.0" - walker@^1.0.7, walker@~1.0.5: version "1.0.7" resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb" From 0df086e07f5186131f96cebe61a57dd145bb3f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 4 Sep 2019 15:38:28 +0200 Subject: [PATCH 3/4] Rename variables --- .../migration/neo4j/contributions/contributions.cql | 8 ++++---- webapp/components/Editor/Editor.vue | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) 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 } From 5d69a6fa76712a01b8eae397e0709dadf3ed0e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 4 Sep 2019 15:56:28 +0200 Subject: [PATCH 4/4] Implemented "wait-on": "~3.3.0" again Don't know why this was removed!? --- backend/package.json | 3 ++- backend/yarn.lock | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/backend/package.json b/backend/package.json index ffc84d64c..b3ec1f593 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/yarn.lock b/backend/yarn.lock index 2ac69e7b3..2829dc9d0 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -752,7 +752,7 @@ resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-8.2.1.tgz#924af04cbb22e17359c620d2a9c946e63f58eb77" integrity sha512-JPiBy+oSmsq3St7XlipfN5pNA6bDJ1kpa73PrK/zR29CVClDVqy04AanM/M/qx5bSF+I61DdCfAvRrujau+zRg== -"@hapi/joi@^15.1.0", "@hapi/joi@^15.1.1": +"@hapi/joi@^15.0.3", "@hapi/joi@^15.1.0", "@hapi/joi@^15.1.1": version "15.1.1" resolved "https://registry.yarnpkg.com/@hapi/joi/-/joi-15.1.1.tgz#c675b8a71296f02833f8d6d243b34c57b8ce19d7" integrity sha512-entf8ZMOK8sc+8YfeOlM8pCfg3b5+WZIKBfUaaJT8UsjAAPjartzxIYm3TIbjvA4u+u++KbcXD38k682nVHDAQ== @@ -7311,7 +7311,7 @@ request-promise-native@^1.0.5: stealthy-require "^1.1.1" tough-cookie "^2.3.3" -request@^2.61.0, request@^2.87.0, request@~2.88.0: +request@^2.61.0, request@^2.87.0, request@^2.88.0, request@~2.88.0: version "2.88.0" resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg== @@ -7447,6 +7447,11 @@ run-async@^2.2.0: dependencies: is-promise "^2.1.0" +rx@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" + integrity sha1-pfE/957zt0D+MKqAP7CfmIBdR4I= + rxjs@^6.4.0: version "6.5.2" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.2.tgz#2e35ce815cd46d84d02a209fb4e5921e051dbec7" @@ -8664,6 +8669,17 @@ w3c-hr-time@^1.0.1: dependencies: browser-process-hrtime "^0.1.2" +wait-on@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/wait-on/-/wait-on-3.3.0.tgz#9940981d047a72a9544a97b8b5fca45b2170a082" + integrity sha512-97dEuUapx4+Y12aknWZn7D25kkjMk16PbWoYzpSdA8bYpVfS6hpl2a2pOWZ3c+Tyt3/i4/pglyZctG3J4V1hWQ== + dependencies: + "@hapi/joi" "^15.0.3" + core-js "^2.6.5" + minimist "^1.2.0" + request "^2.88.0" + rx "^4.1.0" + walker@^1.0.7, walker@~1.0.5: version "1.0.7" resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb"