kulttuuri / SlackNotifications

Slack Mediawiki - Integrate Slack with Mediawiki. Sends notifications into your Slack room when certain actions are being performed in your wiki (for example when article is being edited, new article was added...)

Home Page:https://www.mediawiki.org/wiki/Extension:SlackNotifications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Broken wiki links with spaces

adamsmutnicki opened this issue · comments

Hi,
We started using this extension, which is really nice, but in our case the links to the pages, displayed in the slack channel, are broken. The problem is with how the spaces are encoded, eg: page with title: "Work Tracking" were encoded in the link into: index.php?title=Work%2520tracking which means that space was encoded into %20 and then % sign was encoded into %25. I've checked a code of your extension, and it is not broken, as the link is created properly in the "<a href" tag, but the onclick action added by slack was messing up the rest. So I've done a quick patch, to get rid of spaces from URL. Wiki is using underscore sign for spaces, so a simple change like below resolves the problem, maybe you would like to be interested into incorporating this change.
Line 38 in SlackNotificationsCore.php:
Change from:
$prefix = "<".$wgWikiUrl.$wgWikiUrlEnding.$article->getTitle()->getFullText();
to:
$prefix = "<".$wgWikiUrl.$wgWikiUrlEnding.str_replace(" ", "_", $article->getTitle()->getFullText());
Regards
Adam

Thanks! I'll take a look at this in the weekend, I've been travelling and got ill so last weeks haven't been able to catch up on any stuff :/

Great catch! I've added this in version 1.09. Thanks! :)