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

Redirect to anchors in pages with titles that contain special characters is broken

      NOTE: This bug report is for Confluence Server. Using Confluence Cloud? See the corresponding bug report.

      Symptoms

      When a page name contains a special character, this character is included in the ID of any anchors on the page. When generating the URL for such anchors, Confluence is encoding any text to the right of the # using HTML entity escaping, but for this link to work, it must use URL encoding. This also happens if an anchor name contains a special character.

      For example the apostrophe character:

      • The URL is currently replacing it with '
      • The URL should be replacing it instead with %27 like it does on the left side of the #
      • The anchor is showing up correctly in the page source, as the apostrophe is not encoded inside the id attribute

      Note that whilst using special characters in an ID is prohibited in XML and thus XHTML, it's perfectly fine for HTML5, which is used by Confluence, so any special characters do not need to be encoded inside the id attribute.

      Steps to reproduce:

      1. Create a page named "User's Resources"
      2. Add an anchor to it, say "shares", a link to the anchor in the same page (or any other) and save
      3. Click the link
      4. No redirect is made (or if the link is in a different page, redirect is made only to the page, not the anchor)

      This is the link:

      <confluence_instance>/display/<space_name>/User%27s+Resources#User&#39;sResources-shares

      This behavior happens because of the special character used in the title - If the page is renamed without it, everything works.

      Workaround

      If this is caused by the page name, the only workaround is to rename that page to not have a special character.

      If this is caused by the anchor name, you can work around this by manually URL-escaping the special character in the "Link" value in "Advanced" when creating the link.

            [CONFSERVER-26765] Redirect to anchors in pages with titles that contain special characters is broken

            This is still broken.

            Eligh Corchis-Scott added a comment - This is still broken.

            I have the same issue

            Ruben Elizondo added a comment - I have the same issue

            Alex Reed added a comment -

            Problem is reproduced on Confluence 6.8.2. 

            Alex Reed added a comment - Problem is reproduced on Confluence 6.8.2. 

            David Ma added a comment -

            Hi Xiangfei,

            You will need to upgrade to Confluence 5.2.5 for this fix. (See fix versions above)

            David Ma added a comment - Hi Xiangfei, You will need to upgrade to Confluence 5.2.5 for this fix. (See fix versions above)

            xiangfei.li added a comment -

            It didn't work with IE10. for Confluene v5.1.

            xiangfei.li added a comment - It didn't work with IE10. for Confluene v5.1.

            David Ma added a comment - - edited

            Hi Laura,

            I've managed to reproduce the issue by following the steps in your screen capture. It seems to be a problem when saving links with the apostrophe in the URL, though it looks like you've already found the issue which is related to your bug: CONF-24320

            Please see the following comment which explains why we do not support the apostrophe character: https://jira.atlassian.com/browse/CONF-24320?focusedCommentId=415287&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-415287

            Unfortunately, it seems that manually performing URL encoding on the apostrophe character is the only workaround for now.

            David Ma added a comment - - edited Hi Laura, I've managed to reproduce the issue by following the steps in your screen capture. It seems to be a problem when saving links with the apostrophe in the URL, though it looks like you've already found the issue which is related to your bug: CONF-24320 Please see the following comment which explains why we do not support the apostrophe character: https://jira.atlassian.com/browse/CONF-24320?focusedCommentId=415287&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-415287 Unfortunately, it seems that manually performing URL encoding on the apostrophe character is the only workaround for now.

            It was Chrome.

            As for the apostrophe, that would be a JIRA rendering bug I would think, since I can see the apostrophe in the comment it just hasn't been included in the link?

            Attaching a screencapture of what I did that didn't work that I just took using OnDemand and Chrome in the last 5 minutes (linkproblem.swf). Hopefully, it's clear what I'm doing, but if you have any questions, let me know.

            Oh, and fwiw, my workaround is to manually put urlencoding where the apostrophes belong and that works.

            Laura Kolker added a comment - It was Chrome. As for the apostrophe, that would be a JIRA rendering bug I would think, since I can see the apostrophe in the comment it just hasn't been included in the link? Attaching a screencapture of what I did that didn't work that I just took using OnDemand and Chrome in the last 5 minutes (linkproblem.swf). Hopefully, it's clear what I'm doing, but if you have any questions, let me know. Oh, and fwiw, my workaround is to manually put urlencoding where the apostrophes belong and that works.

            David Ma added a comment - - edited

            Hi Laura,

            Can you advise which browser you are using? It seems to be working fine for me in Chrome and Firefox and IE8.

            Also wondering how you're creating the link to the page because I notice that the autoconvert of the link in your comment has left out the last apostrophe, hence breaking the link to the anchor. I just want to first rule out the possibility of an autoconvert issue.

            David Ma added a comment - - edited Hi Laura, Can you advise which browser you are using? It seems to be working fine for me in Chrome and Firefox and IE8. Also wondering how you're creating the link to the page because I notice that the autoconvert of the link in your comment has left out the last apostrophe, hence breaking the link to the anchor. I just want to first rule out the possibility of an autoconvert issue.

            Laura Kolker added a comment - - edited

            I'm still seeing this problem in OnDemand right now. Trying to link to

            https://confluence.atlassian.com/display/JIRA/Managing+Global+Permissions#ManagingGlobalPermissions-About'JIRASystemAdministrators'and'JIRAAdministrators'
            

            is not working correctly.

            Update: Just realized I meant to use code macro instead of quote. Switching that out.

            Laura Kolker added a comment - - edited I'm still seeing this problem in OnDemand right now. Trying to link to https: //confluence.atlassian.com/display/JIRA/Managing+Global+Permissions#ManagingGlobalPermissions-About 'JIRASystemAdministrators' and 'JIRAAdministrators' is not working correctly. Update: Just realized I meant to use code macro instead of quote. Switching that out.

            David Ma added a comment - - edited

            Looks like the redirect to anchors are still broken in blogposts. The symptoms are as follows:

            • Links to anchors will be HTML escaped, e.g. <a href="#test's-myanchor">test</a>
            • The anchor id will not be HTML escaped, e.g. <span class="confluence-anchor-link" id="test's-myanchor"></span>

            The difference between the encoding will cause the link to break.

            The blogpost fix will be available in Confluence 5.2.5

            David Ma added a comment - - edited Looks like the redirect to anchors are still broken in blogposts. The symptoms are as follows: Links to anchors will be HTML escaped, e.g. <a href="#test's-myanchor">test</a> The anchor id will not be HTML escaped, e.g. <span class="confluence-anchor-link" id="test's-myanchor"></span> The difference between the encoding will cause the link to break. The blogpost fix will be available in Confluence 5.2.5

              dma@atlassian.com David Ma
              363db42e39fc Stefan Uricariu
              Affected customers:
              34 This affects my team
              Watchers:
              79 Start watching this issue

                Created:
                Updated:
                Resolved: