Uploaded image for project: 'XWiki Rendering'
  1. XWiki Rendering
  2. XRENDERING-587

TOC Macro should not fail over empty attachment link

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 12.4
    • Fix Version/s: 12.5-rc-1
    • Component/s: API
    • Labels:
      None
    • Tests:
      Unit
    • Difficulty:
      Trivial
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      If one has a page with the following contents:

      {{toc/}}
      
      == Rubbish [[attach:]]Link ==
      

      then the TOC macro fails with the following error message:

      java.lang.IndexOutOfBoundsException: Index: 0
      	at java.base/java.util.Collections$EmptyList.get(Collections.java:4483)
      	at org.xwiki.rendering.block.PlainTextBlockFilter.filterLinkBlock(PlainTextBlockFilter.java:103)
      	at org.xwiki.rendering.block.PlainTextBlockFilter.filter(PlainTextBlockFilter.java:84)
      	at org.xwiki.rendering.block.AbstractBlock.clone(AbstractBlock.java:520)
      	at org.xwiki.rendering.internal.macro.toc.TocBlockFilter.generateLabel(TocBlockFilter.java:54)
      	at org.xwiki.rendering.internal.macro.toc.TocTreeBuilder.createTocEntry(TocTreeBuilder.java:193)
      	at org.xwiki.rendering.internal.macro.toc.TocTreeBuilder.addItemBlock(TocTreeBuilder.java:166)
      	at org.xwiki.rendering.internal.macro.toc.TocTreeBuilder.generateTree(TocTreeBuilder.java:145)
      	at org.xwiki.rendering.internal.macro.toc.TocTreeBuilder.build(TocTreeBuilder.java:95)
      	at org.xwiki.rendering.internal.macro.toc.AbstractTocMacro.execute(AbstractTocMacro.java:122)
      	at org.xwiki.rendering.internal.macro.toc.AbstractTocMacro.execute(AbstractTocMacro.java:49)
      	at org.xwiki.rendering.internal.transformation.macro.MacroTransformation.transform(MacroTransformation.java:297)
      

      Of course the empty [[attach:]] link is totally useless, but I think it should not make the macro fail, it should just ignore it.

        Attachments

          Activity

            People

            Assignee:
            camil7 Clemens Robbenhaar
            Reporter:
            camil7 Clemens Robbenhaar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: