diff --git a/Changelog.md b/Changelog.md index d534ecf21..e70e51465 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,7 @@ * Prefill conversation form on contacts page only with mutual contacts [#7744](https://github.com/diaspora/diaspora/pull/7744) * Fix profiles sometimes not loading properly in background tabs [#7740](https://github.com/diaspora/diaspora/pull/7740) * Show error message when creating posts with invalid aspects [#7742](https://github.com/diaspora/diaspora/pull/7742) +* Fix mention syntax backport for two immediately consecutive mentions [#7777](https://github.com/diaspora/diaspora/pull/7777) ## Features * Make public stream accessible for logged out users [#7775](https://github.com/diaspora/diaspora/pull/7775) diff --git a/lib/diaspora/mentionable.rb b/lib/diaspora/mentionable.rb index 81ade53b7..59f2da8f0 100644 --- a/lib/diaspora/mentionable.rb +++ b/lib/diaspora/mentionable.rb @@ -72,7 +72,7 @@ module Diaspora::Mentionable end # Regex to find mentions with new syntax, only used for backporting to old syntax - NEW_SYNTAX_REGEX = /@\{[^ ]+\}/ + NEW_SYNTAX_REGEX = /@\{[^\} ]+\}/ # replaces new syntax with old syntax, to be compatible with old pods # @deprecated remove when most of the posts can handle the new syntax diff --git a/spec/lib/diaspora/mentionable_spec.rb b/spec/lib/diaspora/mentionable_spec.rb index aef3e12f4..25926d898 100644 --- a/spec/lib/diaspora/mentionable_spec.rb +++ b/spec/lib/diaspora/mentionable_spec.rb @@ -217,6 +217,13 @@ STR expect(Diaspora::Mentionable.backport_mention_syntax(text)).to eq(expected_text) end + it "replaces the new syntax with the old syntax for immediately consecutive mentions" do + text = "mention @{#{people[0].diaspora_handle}}@{#{people[1].diaspora_handle}} text" + expected_text = "mention @{#{people[0].name}; #{people[0].diaspora_handle}}" \ + "@{#{people[1].name}; #{people[1].diaspora_handle}} text" + expect(Diaspora::Mentionable.backport_mention_syntax(text)).to eq(expected_text) + end + it "removes curly braces from name of the mentioned person when adding it" do profile = FactoryGirl.build(:profile, first_name: "{Alice}", last_name: "(Smith) [123]") person = FactoryGirl.create(:person, profile: profile)