Menu

#105 Page.GetLinks crashes on in-page section links.

closed-fixed
None
2016-02-13
2015-04-06
Korval
No

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.

Discussion

  • CodeDriller

    CodeDriller - 2015-04-08

    You are absolutely right, such links must be ignored.

     
  • CodeDriller

    CodeDriller - 2015-04-08
    • assigned_to: CodeDriller
     
  • CodeDriller

    CodeDriller - 2015-04-08
    • status: open --> confirmed
     
  • CodeDriller

    CodeDriller - 2016-02-13
    • status: confirmed --> closed-fixed
     
  • CodeDriller

    CodeDriller - 2016-02-13

    Fixed in version 3.15.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.