Page.GetLinks crashes on in-page section links.
Make robots for MediaWiki-powered sites!
Brought to you by:
code_driller
Page.GetLinks fails with an exception if one of the links is a pure in-page section link (ie: [[#Section name|Link text]]. It fails because of this:
fragmentPosition = str.IndexOf("#");
if (fragmentPosition != -1)
str = str.Substring(0, fragmentPosition);
If str begins with "#", then fragmentPosition will be 0, which means that the Substring will return an empty string. And Page's constructor obviously can't handle an empty string.
This code should take into account that fragmentPosition could be 0 and either stick the current page into the PageList or ignore the link altogether. Probably the latter.
You are absolutely right, such links must be ignored.
Fixed in version 3.15.