Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-28022

Build description longer than 30 chars has hex zero width space added

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: core
    • Labels:
      None
    • Environment:
      Jenkins 1.596.1, 2.124
    • Similar Issues:
    • Released As:
      Jenkins 2.276

      Description

      We use a Groovy script to write the package version into the build description of a job after it completes. Users then copy this from the Jenkins UI and paste it to perform a deploy. I have discovered occasional strange issues with this where what seems to be a valid version number is not found by our deploy system. Eventually I figured out that Jenkins is inserting a

      ​

      in the string if it exceeds 30 chars. This is invisible (obviously) in the UI but gets captured when the text is selected and copied/pasted (at least with Chrome on MacOS). This is a problem because this copy-paste workflow has been embedded here for several years, and a recent Jenkins upgrade has thrown this entropy into it

        Attachments

          Issue Links

            Activity

            Hide
            danielbeck Daniel Beck added a comment -

            Why is this assigned to me?

            Show
            danielbeck Daniel Beck added a comment - Why is this assigned to me?
            Hide
            danielbeck Daniel Beck added a comment -

            Workaround: Copy it from the build index page.

            Show
            danielbeck Daniel Beck added a comment - Workaround: Copy it from the build index page.
            Hide
            tinro Kevin Wang added a comment -

            Anyone looking at this problem? We are using copy-paste workflow and encountered this problem

            Show
            tinro Kevin Wang added a comment - Anyone looking at this problem? We are using copy-paste workflow and encountered this problem
            Hide
            owenmehegan Owen Mehegan added a comment -

            Tom FENNELLY do you have any thoughts on this? In Chrome this feature does not actually cause the text to wrap, so we get zero width spaces in the string and nothing else in return, it seems.

            Show
            owenmehegan Owen Mehegan added a comment - Tom FENNELLY do you have any thoughts on this? In Chrome this feature does not actually cause the text to wrap, so we get zero width spaces in the string and nothing else in return, it seems.
            Hide
            owenmehegan Owen Mehegan added a comment - - edited

            I take it back - if the build description is just a steady string of alpha characters, it seems to wrap as intended. But when we set the description to the version string that we generate internally (our use case for this), it doesn't wrap at 30 chars. Maybe this is because we always have . and + in the string, among other non-alphanum characters. I just wish there was a better way to get the text to wrap nicely without screwing up the string when we copy and paste it. I had to add a bunch of defensive code to our deploy system so it wouldn't choke on these strings.

            Show
            owenmehegan Owen Mehegan added a comment - - edited I take it back - if the build description is just a steady string of alpha characters, it seems to wrap as intended. But when we set the description to the version string that we generate internally (our use case for this), it doesn't wrap at 30 chars. Maybe this is because we always have . and + in the string, among other non-alphanum characters. I just wish there was a better way to get the text to wrap nicely without screwing up the string when we copy and paste it. I had to add a bunch of defensive code to our deploy system so it wouldn't choke on these strings.
            Hide
            tlopespt Tiago Lopes added a comment -

            I ran into this issue when adding a docker image name to a build's description, which is copy-pasted as input to a pipeline, since the image name was roughly 32 chars long, it was crashing docker with "Invalid reference format", we resolved this problem by sanitizing the pipeline input with:

            image = image.replaceAll("[^-a-zA-Z0-9:._]", "")

            thus removing the extra chars.

            Show
            tlopespt Tiago Lopes added a comment - I ran into this issue when adding a docker image name to a build's description, which is copy-pasted as input to a pipeline, since the image name was roughly 32 chars long, it was crashing docker with "Invalid reference format", we resolved this problem by sanitizing the pipeline input with: image = image.replaceAll( " [^-a-zA-Z0-9:._] " , "" ) thus removing the extra chars.
            Hide
            bwalding Ben Walding added a comment -

            Owen Mehegan - I would completely support you taking on a fix for this - it kills me a little inside every time someone asks me why their deploy didn't work because they sent a corrupted image tag (and I'm not randomly sanitising input against this - as that is yielding to the forces of darkness).

            CSS support for word wrapping is sufficiently straightforward - we should just use it. 

            Show
            bwalding Ben Walding added a comment - Owen Mehegan - I would completely support you taking on a fix for this - it kills me a little inside every time someone asks me why their deploy didn't work because they sent a corrupted image tag (and I'm not randomly sanitising input against this - as that is yielding to the forces of darkness). CSS support for word wrapping is sufficiently straightforward - we should just use it. 
            Hide
            gtirloni Giovanni Tirloni added a comment -

            We've faced this issue on Jenkins 2.8.4 with the GitHub PR Builder plugin where we add the PR's URL to the description. People copy and paste it into their browser's window and, instead of going to the page, Chrome/Firefox won't consider it a URL and instead search for that value.

            Show
            gtirloni Giovanni Tirloni added a comment - We've faced this issue on Jenkins 2.8.4 with the GitHub PR Builder plugin where we add the PR's URL to the description. People copy and paste it into their browser's window and, instead of going to the page, Chrome/Firefox won't consider it a URL and instead search for that value.
            Hide
            encounter Luke Street added a comment -

            We were able to work around this issue by adding the following to our custom theme JS:

            insertZeroWidthSpacesInElementText=function(){}
            Show
            encounter Luke Street added a comment - We were able to work around this issue by adding the following to our custom theme JS: insertZeroWidthSpacesInElementText=function(){}
            Hide
            patrickdepinguin Thomas De Schampheleire added a comment -

            Problem still exists in Jenkins 2, e.g. 2.124.

            We see it not at fixed widths, but at every space of the description string. _See below output, where the actual contents are shown with either xxd or od.

            In xxd you see extra bytes 'e2 80 8b' and in od you see 'b nul vt' (342 200 213).

            echo "(BR: ​5c12ee9f, ​SW: ​28d0325c, ​BLD: ​60.776) " |xxd
            00000000: 2842 523a 20e2 808b 3563 3132 6565 3966 (BR: ...5c12ee9f
            00000010: 2c20 e280 8b53 573a 20e2 808b 3238 6430 , ...SW: ...28d0
            00000020: 3332 3563 2c20 e280 8b42 4c44 3a20 e280 325c, ...BLD: ..
            00000030: 8b36 302e 3737 3629 200a .60.776) .
            
            echo "(BR: ​5c12ee9f, ​SW: ​28d0325c, ​BLD: ​60.776) " |od -ac 
            0000000   (   B   R   :  sp   b nul  vt   5   c   1   2   e   e   9   f
                      (   B   R   :     342 200 213   5   c   1   2   e   e   9   f
            0000020   ,  sp   b nul  vt   S   W   :  sp   b nul  vt   2   8   d   0
                      ,     342 200 213   S   W   :     342 200 213   2   8   d   0
            0000040   3   2   5   c   ,  sp   b nul  vt   B   L   D   :  sp   b nul
                      3   2   5   c   ,     342 200 213   B   L   D   :     342 200
            0000060  vt   6   0   .   7   7   6   )  sp  nl
                    213   6   0   .   7   7   6   )      \n
            0000072
            
            Show
            patrickdepinguin Thomas De Schampheleire added a comment - Problem still exists in Jenkins 2, e.g. 2.124. We see it not at fixed widths, but at every space of the description string. _See below output, where the actual contents are shown with either xxd or od. In xxd you see extra bytes 'e2 80 8b' and in od you see 'b nul vt' (342 200 213). echo "(BR: ​5c12ee9f, ​SW: ​28d0325c, ​BLD: ​60.776) " |xxd 00000000: 2842 523a 20e2 808b 3563 3132 6565 3966 (BR: ...5c12ee9f 00000010: 2c20 e280 8b53 573a 20e2 808b 3238 6430 , ...SW: ...28d0 00000020: 3332 3563 2c20 e280 8b42 4c44 3a20 e280 325c, ...BLD: .. 00000030: 8b36 302e 3737 3629 200a .60.776) . echo "(BR: ​5c12ee9f, ​SW: ​28d0325c, ​BLD: ​60.776) " |od -ac 0000000 ( B R : sp b nul vt 5 c 1 2 e e 9 f ( B R : 342 200 213 5 c 1 2 e e 9 f 0000020 , sp b nul vt S W : sp b nul vt 2 8 d 0 , 342 200 213 S W : 342 200 213 2 8 d 0 0000040 3 2 5 c , sp b nul vt B L D : sp b nul 3 2 5 c , 342 200 213 B L D : 342 200 0000060 vt 6 0 . 7 7 6 ) sp nl 213 6 0 . 7 7 6 ) \n 0000072
            Hide
            patrickdepinguin Thomas De Schampheleire added a comment -

            Workaround suggested by Luke Street indeed works.

            The JavaScript function insertZeroWidthSpacesInElementText is defined and called from war/src/main/webapp/scripts/hudson-behavior.js and indicates that this is actually a feature.

            It was introduced by Tom FENNELLY in commit cb9036c4552 and refined in b31bb1cc1c5.

            Tom FENNELLY, could you give input on this issue, please?

            Show
            patrickdepinguin Thomas De Schampheleire added a comment - Workaround suggested by Luke Street indeed works. The JavaScript function insertZeroWidthSpacesInElementText is defined and called from war/src/main/webapp/scripts/hudson-behavior.js and indicates that this is actually a feature. It was introduced by Tom FENNELLY in commit cb9036c4552 and refined in b31bb1cc1c5. Tom FENNELLY , could you give input on this issue, please?
            Hide
            danielbeck Daniel Beck added a comment -

            I asked in https://github.com/jenkinsci/jenkins/pull/3377 that the author investigates whether a similar approach could be done for this. No response. Perhaps one of the watchers here feels up to the task?

            Show
            danielbeck Daniel Beck added a comment - I asked in https://github.com/jenkinsci/jenkins/pull/3377 that the author investigates whether a similar approach could be done for this. No response. Perhaps one of the watchers here feels up to the task?
            Hide
            woldemar Vladimir Looze added a comment - - edited

            We had just encountered same problem once we started using Build Name Setter Plugin.
            Can confirm that workaround provided by Luke Street does the job - makes build names copy-pasteable.
            As far as I can see this is only reproducible in Build History panel. Everywhere else names of builds were displayed without ​​ in HTML.

            Show
            woldemar Vladimir Looze added a comment - - edited We had just encountered same problem once we started using Build Name Setter Plugin . Can confirm that workaround provided by Luke Street does the job - makes build names copy-pasteable. As far as I can see this is only reproducible in Build History panel. Everywhere else names of builds were displayed without ​ ​ in HTML.
            Hide
            fatcash Alexej Ismailov added a comment - - edited

            Hi, thank you for the suggested workarounds. Pardon my inexperience, do I need to have a custom theme to put Luke Street's JS line? It won't work with stock theme?
            Also waiting for the complete solution, it stole a lot of hours to find the invisible character. Btw, for description the character appears after 30 char and for name (the bold text) its after 20.

            Show
            fatcash Alexej Ismailov added a comment - - edited Hi, thank you for the suggested workarounds. Pardon my inexperience, do I need to have a custom theme to put Luke Street 's JS line? It won't work with stock theme? Also waiting for the complete solution, it stole a lot of hours to find the invisible character. Btw, for description the character appears after 30 char and for name (the bold text) its after 20.
            Hide
            markhu Mark Hudson added a comment -

            Still a problem in Jenkins 2.198 as of September 2020. Duped by JENKINS-40663 

            Show
            markhu Mark Hudson added a comment - Still a problem in Jenkins 2.198 as of September 2020. Duped by  JENKINS-40663  
            Hide
            grzegorz_dubicki Greg Dubicki added a comment -

            I just created a PR for just removing zero-width space adding altogether: https://github.com/jenkinsci/jenkins/pull/5021/files

            Show
            grzegorz_dubicki Greg Dubicki added a comment - I just created a PR for just removing zero-width space adding altogether: https://github.com/jenkinsci/jenkins/pull/5021/files
            Hide
            owenmehegan Owen Mehegan added a comment -

            Hallelujah.

            Show
            owenmehegan Owen Mehegan added a comment - Hallelujah.

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              owenmehegan Owen Mehegan
              Votes:
              19 Vote for this issue
              Watchers:
              25 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: