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

CreateItem with rest api impossible with some character

    Details

    • Similar Issues:

      Description

      When I would create a new job with the xml rest api route, and a description with special character as &, then jenkins server answer a 500 internal server error to my postman.

      If the description value contains any special character, then it's working correctly.

       

      My url : <jenkinsUrl>/createItem?name=yatho-test

      Header : content-type : application/xml

      Basic authent for the credentials

      Body :

      <?xml version='1.1' encoding='UTF-8'?>
      <org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject plugin="workflow-multibranch@2.21">
       <actions/>
       <description>I am testing & and é and á ...</description>
       <properties>
       <org.jenkinsci.plugins.pipeline.maven.MavenConfigFolderOverrideProperty plugin="pipeline-maven@3.8.1">
       <settings class="jenkins.mvn.DefaultSettingsProvider"/>
       <globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>
       <override>false</override>
       </org.jenkinsci.plugins.pipeline.maven.MavenConfigFolderOverrideProperty>
       <org.jenkinsci.plugins.pipeline.modeldefinition.config.FolderConfig plugin="pipeline-model-definition@1.3.9">
       <dockerLabel></dockerLabel>
       <registry plugin="docker-commons@1.15"/>
       </org.jenkinsci.plugins.pipeline.modeldefinition.config.FolderConfig>
       </properties>
       <folderViews class="jenkins.branch.MultiBranchProjectViewHolder" plugin="branch-api@2.5.4">
       <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
       </folderViews>
       <healthMetrics>
       <com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric plugin="cloudbees-folder@6.9">
       <nonRecursive>false</nonRecursive>
       </com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric>
       </healthMetrics>
       <icon class="jenkins.branch.MetadataActionFolderIcon" plugin="branch-api@2.5.4">
       <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
       </icon>
       <orphanedItemStrategy class="com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy" plugin="cloudbees-folder@6.9">
       <pruneDeadBranches>true</pruneDeadBranches>
       <daysToKeep>-1</daysToKeep>
       <numToKeep>-1</numToKeep>
       </orphanedItemStrategy>
       <triggers/>
       <disabled>false</disabled>
       <sources class="jenkins.branch.MultiBranchProject$BranchSourceList" plugin="branch-api@2.5.4">
       <data>
       <jenkins.branch.BranchSource>
       <source class="jenkins.plugins.git.GitSCMSource" plugin="git@3.11.0">
       <id>9a22b5bd-233e-4dfb-b703-bd64f0b45eb9</id>
       <remote>https://github.com/hm-it-test/yatho-test</remote>
       <credentialsId>myToken</credentialsId>
       <traits>
       <jenkins.plugins.git.traits.BranchDiscoveryTrait/>
       <jenkins.plugins.git.traits.LocalBranchTrait>
       <extension class="hudson.plugins.git.extensions.impl.LocalBranch">
       <localBranch>**</localBranch>
       </extension>
       </jenkins.plugins.git.traits.LocalBranchTrait>
       </traits>
       </source>
       <strategy class="jenkins.branch.DefaultBranchPropertyStrategy">
       <properties class="java.util.Arrays$ArrayList">
       <a class="jenkins.branch.BranchProperty-array">
       <jenkins.branch.NoTriggerBranchProperty/>
       </a>
       </properties>
       </strategy>
       </jenkins.branch.BranchSource>
       </data>
       <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
       </sources>
       <factory class="org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory">
       <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
       <scriptPath>Jenkinsfile</scriptPath>
       </factory>
      </org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject>
      

        Attachments

          Activity

          Hide
          jcordoba Jorge Cordoba added a comment -

          I would like to try and fix this if no one is working in it.

          Show
          jcordoba Jorge Cordoba added a comment - I would like to try and fix this if no one is working in it.
          Hide
          jcordoba Jorge Cordoba added a comment - - edited

          Yann-Thomas Le Moigne, it seems you are not escaping the & in your XML body.

          For XML files the ilegal characters are &< and > (as well as " or ' in attributes).

          Writing "&+amp;" (without the + sign) instead of "&" should have no problems.
          As far as I can tell this is not a Jenkins issue, but an issue in the side of the one who sends the xml file.

          Show
          jcordoba Jorge Cordoba added a comment - - edited Yann-Thomas Le Moigne , it seems you are not escaping the & in your XML body. For XML files the ilegal characters are  & ,  <  and  >  (as well as  "  or  '  in attributes). Writing "&+amp;" (without the + sign) instead of "&" should have no problems. As far as I can tell this is not a Jenkins issue, but an issue in the side of the one who sends the xml file.
          Hide
          yatho Yann-Thomas Le Moigne added a comment - - edited

          I am using CDATA for escape xml value in this case. Thank you. I think this ticket could be closed.

          Show
          yatho Yann-Thomas Le Moigne added a comment - - edited I am using CDATA for escape xml value in this case. Thank you. I think this ticket could be closed.
          Hide
          jcordoba Jorge Cordoba added a comment -

          Seems the & was not being escaped in the xml.

          For XML files the ilegal characters are &, < and > (as well as " or ' in attributes).

          Writing "&+amp;" (without the + sign) instead of "&" should have no problems.
          As far as I can tell this is not a Jenkins issue, but an issue in the side of the one who sends the xml file.

          Show
          jcordoba Jorge Cordoba added a comment - Seems the & was not being escaped in the xml. For XML files the ilegal characters are &, < and > (as well as " or ' in attributes). Writing "&+amp;" (without the + sign) instead of "&" should have no problems. As far as I can tell this is not a Jenkins issue, but an issue in the side of the one who sends the xml file.

            People

            • Assignee:
              jcordoba Jorge Cordoba
              Reporter:
              yatho Yann-Thomas Le Moigne
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: