Re: [Wikitech-l] Linker::link() rewrite
Hi, On 05/16/2016 07:51 AM, Chris Steipp wrote: > Is there any way we can default to having the body of the link not be > passed as html? It's called $html, well documented that it's raw html, and > I've lost track of the number of times people pass unsanitized text to it. > I'd rather it not be something developers have to worry about, unless they > know they need to handle the sanitization themselves. Maybe typehint a > Message object, and people can add raw params if they really need to send > it raw html? Yeah, that sounds good, I implemented that change in PS22. Clients that still need to pass in raw HTML can use the new MediaWiki\Linker\HtmlArmor class to prevent it from being escaped. -- Legoktm ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: [Wikitech-l] Linker::link() rewrite
+1 I don't think I ever used that function with actual html, but more than once I had to fiddle with escaping. I'm fairly sure it's hardly ever used with with html. Cheers, Marius On 16.05.2016 16:51, Chris Steipp wrote: Is there any way we can default to having the body of the link not be passed as html? It's called $html, well documented that it's raw html, and I've lost track of the number of times people pass unsanitized text to it. I'd rather it not be something developers have to worry about, unless they know they need to handle the sanitization themselves. Maybe typehint a Message object, and people can add raw params if they really need to send it raw html? On Sun, May 15, 2016 at 4:28 PM, Legoktmwrote: Hi, For the past few weeks I've been working[1] on rewriting Linker::link() to be non-static, use LinkTarget/TitleValue and some of the other fancy new services stuff. Yay! For the most part, you'd use it in similar ways: Linker::link( $title, $html, $attribs, $query ); is now: $linkRenderer = MediaWikiServices::getInstance() ->getHtmlPageLinkRenderer(); $linkRenderer->makeLink( $title, $html, $attribs, $query ); And there are makeKnownLink() and makeBrokenLink() entry points as well. Unlike Linker::link(), there is no $options parameter to pass in every time a link needs to be made. Those options are set on the HtmlPageLinkRenderer instance, and then applied to all links made using it. MediaWikiServices has an instance using the default settings, but other classes like Parser will have their own that should be used[2]. I'm also deprecating the two hooks called by Linker::link(), LinkBegin and LinkEnd. They are being replaced by the mostly-equivalent HtmlPageLinkRendererBegin and HtmlPageLinkRendererEnd hooks. More details are in the commit message. [3] is an example conversion for Wikibase. The commit is still a WIP because I haven't gotten around to writing specific tests for it (it passes all the pre-existing Linker and parser tests though!), and will be doing that in the next few days. Regardless, reviews / comments / feedback on [1] is appreciated! [1] https://gerrit.wikimedia.org/r/#/c/284750/ [2] https://gerrit.wikimedia.org/r/#/c/288572/ [3] https://gerrit.wikimedia.org/r/#/c/288674/ -- Legoktm ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: [Wikitech-l] Linker::link() rewrite
Is there any way we can default to having the body of the link not be passed as html? It's called $html, well documented that it's raw html, and I've lost track of the number of times people pass unsanitized text to it. I'd rather it not be something developers have to worry about, unless they know they need to handle the sanitization themselves. Maybe typehint a Message object, and people can add raw params if they really need to send it raw html? On Sun, May 15, 2016 at 4:28 PM, Legoktmwrote: > Hi, > > For the past few weeks I've been working[1] on rewriting Linker::link() > to be non-static, use LinkTarget/TitleValue and some of the other fancy > new services stuff. Yay! > > For the most part, you'd use it in similar ways: > Linker::link( $title, $html, $attribs, $query ); > is now: > $linkRenderer = MediaWikiServices::getInstance() >->getHtmlPageLinkRenderer(); > $linkRenderer->makeLink( $title, $html, $attribs, $query ); > > And there are makeKnownLink() and makeBrokenLink() entry points as well. > > Unlike Linker::link(), there is no $options parameter to pass in every > time a link needs to be made. Those options are set on the > HtmlPageLinkRenderer instance, and then applied to all links made using > it. MediaWikiServices has an instance using the default settings, but > other classes like Parser will have their own that should be used[2]. > > I'm also deprecating the two hooks called by Linker::link(), LinkBegin > and LinkEnd. They are being replaced by the mostly-equivalent > HtmlPageLinkRendererBegin and HtmlPageLinkRendererEnd hooks. More > details are in the commit message. [3] is an example conversion for > Wikibase. > > The commit is still a WIP because I haven't gotten around to writing > specific tests for it (it passes all the pre-existing Linker and parser > tests though!), and will be doing that in the next few days. > > Regardless, reviews / comments / feedback on [1] is appreciated! > > [1] https://gerrit.wikimedia.org/r/#/c/284750/ > [2] https://gerrit.wikimedia.org/r/#/c/288572/ > [3] https://gerrit.wikimedia.org/r/#/c/288674/ > > -- Legoktm > > ___ > Wikitech-l mailing list > Wikitech-l@lists.wikimedia.org > https://lists.wikimedia.org/mailman/listinfo/wikitech-l ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
[Wikitech-l] Linker::link() rewrite
Hi, For the past few weeks I've been working[1] on rewriting Linker::link() to be non-static, use LinkTarget/TitleValue and some of the other fancy new services stuff. Yay! For the most part, you'd use it in similar ways: Linker::link( $title, $html, $attribs, $query ); is now: $linkRenderer = MediaWikiServices::getInstance() ->getHtmlPageLinkRenderer(); $linkRenderer->makeLink( $title, $html, $attribs, $query ); And there are makeKnownLink() and makeBrokenLink() entry points as well. Unlike Linker::link(), there is no $options parameter to pass in every time a link needs to be made. Those options are set on the HtmlPageLinkRenderer instance, and then applied to all links made using it. MediaWikiServices has an instance using the default settings, but other classes like Parser will have their own that should be used[2]. I'm also deprecating the two hooks called by Linker::link(), LinkBegin and LinkEnd. They are being replaced by the mostly-equivalent HtmlPageLinkRendererBegin and HtmlPageLinkRendererEnd hooks. More details are in the commit message. [3] is an example conversion for Wikibase. The commit is still a WIP because I haven't gotten around to writing specific tests for it (it passes all the pre-existing Linker and parser tests though!), and will be doing that in the next few days. Regardless, reviews / comments / feedback on [1] is appreciated! [1] https://gerrit.wikimedia.org/r/#/c/284750/ [2] https://gerrit.wikimedia.org/r/#/c/288572/ [3] https://gerrit.wikimedia.org/r/#/c/288674/ -- Legoktm ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l