Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-13701

#renderItemLink has Velocity scoping issues

    XMLWordPrintable

Details

    Description

      Using a web item that has no URL set causes the web item to inherit the previously rendered web item's URL.

      Offending code:

      #macro (renderItemLink $item $isCurrent)
          #set ($itemRenderedUrl = $item.link.getDisplayableUrl($req, $action.webInterfaceContext))
      [...]
          <a #if ($item.link.id) id="$item.link.id"#end href="$itemRenderedUrl" #if ($itemClass) class="$itemClass"#end #if ($item.link.hasAccessKey()) accessKey="$item.link.getAccessKey($helper)"#end #if ($itemTooltip) title="$itemTooltip"#end>
      

      If no URL is set on the web item, getDisplayableUrl returns null, but Velocity doesn't set $itemRenderedUrl as null. Furthermore, $itemRenderedUrl hangs around in the Velocity context – which has the effect that the previous web item's URL is outputted.

      This would also be an issue for all the other variables.

      Furthermore, we should wrap the href attribute on the <a> with an if statement, to allow web items to omit the URL.

      Attachments

        Activity

          People

            cbroadfoot Chris Broadfoot [Atlassian]
            cbroadfoot Chris Broadfoot [Atlassian]
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: