[JIRA] (JENKINS-60307) CreateItem with rest api impossible with some character

16 views
Skip to first unread message

yann.tho.le.moigne@gmail.com (JIRA)

unread,
Nov 27, 2019, 12:22:02 PM11/27/19
to jenkinsc...@googlegroups.com
Yann-Thomas Le Moigne created an issue
 
Jenkins / Bug JENKINS-60307
CreateItem with rest api impossible with some character
Issue Type: Bug Bug
Assignee: Unassigned
Attachments: resultCreateItemWithSpecialCharacter.PNG
Components: core
Created: 2019-11-27 17:21
Labels: api createItem
Priority: Minor Minor
Reporter: Yann-Thomas Le Moigne

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-m...@2.21">
 <actions/>
 <description>I am testing & and é and á ...</description>
 <properties>
 <org.jenkinsci.plugins.pipeline.maven.MavenConfigFolderOverrideProperty plugin="pipelin...@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-mod...@1.3.9">
 <dockerLabel></dockerLabel>
 <registry plugin="docker-...@1.15"/>
 </org.jenkinsci.plugins.pipeline.modeldefinition.config.FolderConfig>
 </properties>
 <folderViews class="jenkins.branch.MultiBranchProjectViewHolder" plugin="branc...@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="branc...@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="branc...@2.5.4">
 <data>
 <jenkins.branch.BranchSource>
 <source class="jenkins.plugins.git.GitSCMSource" plugin="g...@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>
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

jorgecordoba95@gmail.com (JIRA)

unread,
Nov 27, 2019, 6:42:02 PM11/27/19
to jenkinsc...@googlegroups.com
Jorge Cordoba commented on Bug JENKINS-60307
 
Re: CreateItem with rest api impossible with some character

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

jorgecordoba95@gmail.com (JIRA)

unread,
Nov 27, 2019, 6:51:02 PM11/27/19
to jenkinsc...@googlegroups.com
Jorge Cordoba started work on Bug JENKINS-60307
 
Change By: Jorge Cordoba
Status: Open In Progress

jorgecordoba95@gmail.com (JIRA)

unread,
Nov 27, 2019, 6:51:03 PM11/27/19
to jenkinsc...@googlegroups.com

jorgecordoba95@gmail.com (JIRA)

unread,
Nov 27, 2019, 7:09:04 PM11/27/19
to jenkinsc...@googlegroups.com
 
Re: CreateItem with rest api impossible with some character

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 "&" 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.

jorgecordoba95@gmail.com (JIRA)

unread,
Nov 27, 2019, 7:10:13 PM11/27/19
to jenkinsc...@googlegroups.com
Jorge Cordoba edited a comment on Bug JENKINS-60307
[~yatho], 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;" 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.

jorgecordoba95@gmail.com (JIRA)

unread,
Nov 27, 2019, 7:12:02 PM11/27/19
to jenkinsc...@googlegroups.com
Jorge Cordoba edited a comment on Bug JENKINS-60307
[~yatho], 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.

yann.tho.le.moigne@gmail.com (JIRA)

unread,
Nov 28, 2019, 4:17:04 AM11/28/19
to jenkinsc...@googlegroups.com
I am using CDATA for escape xml value in this case. Thank you. I think this ticket could be closed.

yann.tho.le.moigne@gmail.com (JIRA)

unread,
Nov 28, 2019, 4:17:04 AM11/28/19
to jenkinsc...@googlegroups.com
 
Re: CreateItem with rest api impossible with some character

I am using CDATA for escape xml value in this case. Thank you.

jorgecordoba95@gmail.com (JIRA)

unread,
Nov 28, 2019, 10:53:02 AM11/28/19
to jenkinsc...@googlegroups.com

jorgecordoba95@gmail.com (JIRA)

unread,
Nov 29, 2019, 2:47:03 PM11/29/19
to jenkinsc...@googlegroups.com
 

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.

Change By: Jorge Cordoba
Status: In Review Resolved
Resolution: Not A Defect
Reply all
Reply to author
Forward
0 new messages