Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text duplication fix #137

Merged
merged 3 commits into from
Aug 11, 2021
Merged

Text duplication fix #137

merged 3 commits into from
Aug 11, 2021

Conversation

tsmethurst
Copy link
Contributor

Closes #134

From matrix conversation:

The problem was exactly here: https://github.com/superseriousbusiness/gotosocial/blob/main/internal/text/common.go#L62

Instead of returning in if no matching tags are found, it should return match.

So basically what happened in that function was that the hashtagfinderregex matched #Hashtag in the string, then it started iterating through the list of tags looking for the replacement... HOWEVER, tag.Name was automatically lowercased by some of the text parsing functionality from earlier

which means that strings.TrimSpace(match) == fmt.Sprintf("#%s", tag.Name) was not true

so the fallback behavior was to return in, which is the whole status

so #Hashtag was being replaced by ALL of in

so the two fixes are to:

  1. make that match case insensitive using strings.EqualFold instead of ==
  2. return match instead of in so nothing is replaced in case a tag can't be found

@tsmethurst tsmethurst merged commit 329a5e8 into main Aug 11, 2021
@tsmethurst tsmethurst deleted the text_duplication_fix branch August 11, 2021 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text duplication within posts containing hashtags and links
1 participant