diff --git a/backend/src/middleware/hashtags/extractHashtags.js b/backend/src/middleware/hashtags/extractHashtags.js index c7782e59d..13f29475e 100644 --- a/backend/src/middleware/hashtags/extractHashtags.js +++ b/backend/src/middleware/hashtags/extractHashtags.js @@ -20,7 +20,7 @@ export default function(content) { .get() const hashtags = [] urls.forEach(url => { - const match = exec(url, regX) + const match = exec(decodeURI(url), regX) if (match != null) { hashtags.push(match[1]) } diff --git a/backend/src/middleware/hashtags/extractHashtags.spec.js b/backend/src/middleware/hashtags/extractHashtags.spec.js index 2e1761718..0881e33a3 100644 --- a/backend/src/middleware/hashtags/extractHashtags.spec.js +++ b/backend/src/middleware/hashtags/extractHashtags.spec.js @@ -27,14 +27,14 @@ describe('extractHashtags', () => { expect(extractHashtags(content)).toEqual(['Democracy']) }) - it('ignores Hashtag links with not allowed character combinations', () => { + it('ignores Hashtag links with not allowed character combinations and handles `encodeURI` URLs', () => { // 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 #λαπ.

' + '

Something inspirational about #AbcDefXyz0123456789!*(),2, #0123456789, #0123456789a, #AbcDefXyz0123456789, and #ħπαλ.

' expect(extractHashtags(content).sort()).toEqual([ '0123456789a', 'AbcDefXyz0123456789', - 'λαπ', + 'ħπαλ', ]) }) }) diff --git a/backend/src/middleware/hashtags/hashtagsMiddleware.spec.js b/backend/src/middleware/hashtags/hashtagsMiddleware.spec.js index 3f101f778..16cd96eb7 100644 --- a/backend/src/middleware/hashtags/hashtagsMiddleware.spec.js +++ b/backend/src/middleware/hashtags/hashtagsMiddleware.spec.js @@ -129,8 +129,8 @@ describe('hashtags', () => { ) }) - describe('afterwards update the Post by removing a Hashtag, leaving a Hashtag and add a Hashtag', () => { - // The already existing Hashtag has no class at this point. + describe('afterwards update the Post by removing a hashtag, leaving a hashtag and add a hashtag', () => { + // The already existing hashtag has no class at this point. const postContent = '

Hey Dude, #Elections should work equal for everybody!? That seems to be the only way to have equal #Liberty for everyone.

' diff --git a/webapp/components/Editor/nodes/Hashtag.js b/webapp/components/Editor/nodes/Hashtag.js index 97220668f..bf1530ceb 100644 --- a/webapp/components/Editor/nodes/Hashtag.js +++ b/webapp/components/Editor/nodes/Hashtag.js @@ -25,7 +25,7 @@ export default class Hashtag extends TipTapMention { 'a', { class: this.options.mentionClass, - href: `/search/hashtag/${node.attrs.id}`, + href: `/search/hashtag/${encodeURI(node.attrs.id)}`, 'data-hashtag-id': node.attrs.id, target: '_blank', }, diff --git a/webapp/pages/admin/tags.vue b/webapp/pages/admin/tags.vue index 9ede1d502..e068d68fa 100644 --- a/webapp/pages/admin/tags.vue +++ b/webapp/pages/admin/tags.vue @@ -5,7 +5,7 @@ {{ scope.index + 1 }}. diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue index 31e07f382..99668f67a 100644 --- a/webapp/pages/index.vue +++ b/webapp/pages/index.vue @@ -75,7 +75,8 @@ export default { MasonryGridItem, }, data() { - const { hashtag = null } = this.$route.query + let { hashtag = null } = this.$route.query + hashtag = decodeURI(hashtag) return { posts: [], hasMore: true, diff --git a/webapp/pages/search/hashtag/_id.vue b/webapp/pages/search/hashtag/_id.vue index d180b4e4f..f501b67bc 100644 --- a/webapp/pages/search/hashtag/_id.vue +++ b/webapp/pages/search/hashtag/_id.vue @@ -5,8 +5,9 @@