Steps to reproduce:
- Add a comment with an external link to a wikipage with an illegal character (here it is |): [https://fr.wikipedia.org/wiki/MediaWiki| Test].
- Save the comment.
- Refresh the page.
- Yay the TypeError!
In this case, title = getPageTitleFromUri( "https://fr.wikipedia.org/wiki/MediaWiki|" ) returns MediaWiki| and mwTitle = mw.Title.newFromText( title ) returns null.
The very first check on the title causes the TypeError.
Here an example. Can be reproduced with an external link to any edition (e.g: [https://en.wikipedia.org/wiki/MediaWiki| Test]). I hope it's complete, I just ran into it by coincidence.