Uploaded image for project: 'Jira Service Management Data Center'
  1. Jira Service Management Data Center
  2. JSDSERVER-6082

Opening an attachment linked using link notation (with pipeline) on Customer portal results in 403 Forbidden error

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Highest Highest
    • 3.16.2, 4.1.0
    • 3.15.1, 3.16.1
    • Customer Portal

      Summary

      Opening an attachment on Customer portal that was linked using link notation (with pipeline) results in 403 Forbidden error

      Steps to Reproduce

      As an agent:

      1. Log in as an agent and open a ticket
      2. Attach a file and refer to it in a comment using pipeline:
        [Example|^example.txt]

        The file gets attached:

      As a customer:

      1. Access the ticket via Customer portal
      2. Open the attached file

      Expected Results

      Customer on the portal is able to access the attachment.

      Actual Results

      Customer on the portal is not able to access the attachments as the 403 Forbidden error gets displayed:

      Workaround

      Avoid using pipeline notation for link by attaching the file using the following notation:

       [^example.txt] 

      Note

      – The file can be accessed through the agent view
      – This cannot be reproduced on some earlier versions (tested on Service Desk 3.11.1)

        1. screenshot-1.png
          screenshot-1.png
          7 kB
        2. screenshot-2.png
          screenshot-2.png
          17 kB

          Form Name

            [JSDSERVER-6082] Opening an attachment linked using link notation (with pipeline) on Customer portal results in 403 Forbidden error

            Rodrigo Jose Zaparoli made changes -
            Remote Link Original: This issue links to "JSDS-3502 (Bulldog)" [ 409988 ] New: This issue links to "JSMDC-3502 (JIRA Server (Bulldog))" [ 409988 ]
            set-jac-bot made changes -

            Hi,

            I want to share the workaround I have develop for this bug.

            I discovered that if the linked file is also linked in another comment without alias, the links with alias works.

            With that info, I have created a Script Runner Listener on comment creation and comment edition of Service Desk projects.

            If a public comment is created or edited, and that comment contains file links with alias, the script cretes a new comment only with the linked files, but this time without alias:

            import com.atlassian.jira.bc.issue.comment.property.CommentPropertyService
            import com.atlassian.jira.component.ComponentAccessor
            import com.atlassian.jira.event.issue.IssueEvent
            import com.atlassian.jira.issue.comments.Comment
            import groovy.json.JsonSlurper
            import java.util.regex.*
            
            final SD_PUBLIC_COMMENT = "sd.public.comment"
            
            def event = event as IssueEvent
            def user = event.getUser()
            def comment = event.getComment()
            def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)
            
            def isInternal = { Comment c ->
              def commentProperty = commentPropertyService.getProperty(user, c.id, SD_PUBLIC_COMMENT)
              .getEntityProperty().getOrNull()
            
              if (commentProperty) {
                def props = new JsonSlurper().parseText(commentProperty.getValue())
                props['internal'].toBoolean()
              } else {
                null
              }
            }
            
            if (comment && !isInternal(comment)) {
              String txt = comment.getBody()
            
              def files = []
              Pattern filepat = Pattern.compile("\\[.*\\|\\^(.*)\\]")
              Matcher m = filepat.matcher(txt)
              while (m.find()) {
                files << "[^"+m.group(1)+"]"
              }
            
              if(files){
                def commentManager = ComponentAccessor.getCommentManager()
                commentManager.create(issue, comment.getAuthor(), files.join("\n"), false)
              }
            }

            This way, the original alias link works ok.

            I hope this may help.

            Regards.

            Manuel Jesús Morión Barea added a comment - - edited Hi, I want to share the workaround I have develop for this bug. I discovered that if the linked file is also linked in another comment without alias, the links with alias works. With that info, I have created a Script Runner Listener on comment creation and comment edition of Service Desk projects. If a public comment is created or edited, and that comment contains file links with alias, the script cretes a new comment only with the linked files, but this time without alias: import com.atlassian.jira.bc.issue.comment.property.CommentPropertyService import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.event.issue.IssueEvent import com.atlassian.jira.issue.comments.Comment import groovy.json.JsonSlurper import java.util.regex.* final SD_PUBLIC_COMMENT = "sd. public .comment" def event = event as IssueEvent def user = event.getUser() def comment = event.getComment() def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService) def isInternal = { Comment c -> def commentProperty = commentPropertyService.getProperty(user, c.id, SD_PUBLIC_COMMENT) .getEntityProperty().getOrNull() if (commentProperty) { def props = new JsonSlurper().parseText(commentProperty.getValue()) props[ 'internal' ].toBoolean() } else { null } } if (comment && !isInternal(comment)) { String txt = comment.getBody() def files = [] Pattern filepat = Pattern.compile( "\\[.*\\|\\^(.*)\\]" ) Matcher m = filepat.matcher(txt) while (m.find()) { files << "[^" +m.group(1)+ "]" } if (files){ def commentManager = ComponentAccessor.getCommentManager() commentManager.create(issue, comment.getAuthor(), files.join( "\n" ), false ) } } This way, the original alias link works ok. I hope this may help. Regards.
            Julien Rey made changes -
            Remote Link New: This issue links to "Page (Confluence)" [ 419502 ]
            moofoo (Inactive) made changes -
            Fix Version/s Original: 4.0.3 [ 85793 ]
            Lachlan G (Inactive) made changes -
            Resolution New: Fixed [ 1 ]
            Status Original: Waiting for Release [ 12075 ] New: Closed [ 6 ]
            Bugfix Automation Bot made changes -
            Support reference count Original: 16 New: 17
            SET Analytics Bot made changes -
            UIS Original: 116 New: 51
            Lachlan G (Inactive) made changes -
            Fix Version/s New: 4.1.0 [ 85506 ]
            SET Analytics Bot made changes -
            UIS Original: 110 New: 116

              amelnikau Aliaksei Melnikau (Inactive)
              mfilipan Marko Filipan
              Affected customers:
              19 This affects my team
              Watchers:
              26 Start watching this issue

                Created:
                Updated:
                Resolved: