Fix multibyte character problem
Fixed problem that causes a UnicodeEncodeError when use multi-byte characters in the job.yml. Change-Id: Ie715c827a794e73fae11cdca079ea80cfb8c280d
This commit is contained in:
parent
777a29aa8a
commit
604d39305b
@ -381,7 +381,7 @@ class XmlJob(object):
|
|||||||
|
|
||||||
def output(self):
|
def output(self):
|
||||||
out = minidom.parseString(XML.tostring(self.xml))
|
out = minidom.parseString(XML.tostring(self.xml))
|
||||||
out = out.toprettyxml(indent=' ')
|
out = out.toprettyxml(indent=' ', encoding='utf-8')
|
||||||
return self.pretty_text_re.sub('>\g<1></', out)
|
return self.pretty_text_re.sub('>\g<1></', out)
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import codecs
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import doctest
|
import doctest
|
||||||
@ -61,7 +62,7 @@ class BaseTestCase(object):
|
|||||||
def __read_content(self):
|
def __read_content(self):
|
||||||
# Read XML content, assuming it is unicode encoded
|
# Read XML content, assuming it is unicode encoded
|
||||||
xml_filepath = os.path.join(self.fixtures_path, self.xml_filename)
|
xml_filepath = os.path.join(self.fixtures_path, self.xml_filename)
|
||||||
xml_content = u"%s" % open(xml_filepath, 'r').read()
|
xml_content = u"%s" % codecs.open(xml_filepath, 'r', 'utf-8').read()
|
||||||
|
|
||||||
yaml_filepath = os.path.join(self.fixtures_path, self.yaml_filename)
|
yaml_filepath = os.path.join(self.fixtures_path, self.yaml_filename)
|
||||||
with file(yaml_filepath, 'r') as yaml_file:
|
with file(yaml_filepath, 'r') as yaml_file:
|
||||||
@ -83,7 +84,8 @@ class BaseTestCase(object):
|
|||||||
pub.gen_xml(parser, xml_project, yaml_content)
|
pub.gen_xml(parser, xml_project, yaml_content)
|
||||||
|
|
||||||
# Prettify generated XML
|
# Prettify generated XML
|
||||||
pretty_xml = XmlJob(xml_project, 'fixturejob').output()
|
pretty_xml = unicode(XmlJob(xml_project, 'fixturejob').output(),
|
||||||
|
'utf-8')
|
||||||
|
|
||||||
self.assertThat(
|
self.assertThat(
|
||||||
pretty_xml,
|
pretty_xml,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<builders>
|
<builders>
|
||||||
<hudson.tasks.Maven>
|
<hudson.tasks.Maven>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<builders>
|
<builders>
|
||||||
<hudson.tasks.Maven>
|
<hudson.tasks.Maven>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<builders>
|
<builders>
|
||||||
<hudson.plugins.parameterizedtrigger.TriggerBuilder>
|
<hudson.plugins.parameterizedtrigger.TriggerBuilder>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<actions/>
|
<actions/>
|
||||||
<keepDependencies>false</keepDependencies>
|
<keepDependencies>false</keepDependencies>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<actions/>
|
<actions/>
|
||||||
<keepDependencies>false</keepDependencies>
|
<keepDependencies>false</keepDependencies>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<properties>
|
<properties>
|
||||||
<com.tikal.hudson.plugins.notification.HudsonNotificationProperty>
|
<com.tikal.hudson.plugins.notification.HudsonNotificationProperty>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<properties>
|
<properties>
|
||||||
<hudson.model.ParametersDefinitionProperty>
|
<hudson.model.ParametersDefinitionProperty>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<properties>
|
<properties>
|
||||||
<hudson.plugins.batch__task.BatchTaskProperty>
|
<hudson.plugins.batch__task.BatchTaskProperty>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<properties>
|
<properties>
|
||||||
<hudson.plugins.throttleconcurrents.ThrottleJobProperty>
|
<hudson.plugins.throttleconcurrents.ThrottleJobProperty>
|
||||||
|
@ -10,5 +10,5 @@ Each yaml file MUST have a corresponding xml file.
|
|||||||
|
|
||||||
Once the YAML file has been parsed, it is prettify using python minidom
|
Once the YAML file has been parsed, it is prettify using python minidom
|
||||||
which also means that:
|
which also means that:
|
||||||
- your XML file must start with: <?xml version="1.0" ?>
|
- your XML file must start with: <?xml version="1.0" encoding="utf-8"?>
|
||||||
- self closing elements do not contains space eg: <element/>
|
- self closing elements do not contains space eg: <element/>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.tasks.ArtifactArchiver>
|
<hudson.tasks.ArtifactArchiver>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.blame__upstream__commiters.BlameUpstreamCommitersPublisher/>
|
<hudson.plugins.blame__upstream__commiters.BlameUpstreamCommitersPublisher/>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.build__publisher.BuildPublisher>
|
<hudson.plugins.build__publisher.BuildPublisher>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<org.jenkinsci.plugins.cloverphp.CloverPHPPublisher>
|
<org.jenkinsci.plugins.cloverphp.CloverPHPPublisher>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<org.jenkinsci.plugins.cloverphp.CloverPHPPublisher>
|
<org.jenkinsci.plugins.cloverphp.CloverPHPPublisher>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<org.jenkinsci.plugins.cloverphp.CloverPHPPublisher>
|
<org.jenkinsci.plugins.cloverphp.CloverPHPPublisher>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.descriptionsetter.DescriptionSetterPublisher>
|
<hudson.plugins.descriptionsetter.DescriptionSetterPublisher>
|
12
tests/publishers/fixtures/description-setter002.xml
Normal file
12
tests/publishers/fixtures/description-setter002.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<hudson.plugins.descriptionsetter.DescriptionSetterPublisher>
|
||||||
|
<regexp>.*(<a href=.*a>)</regexp>
|
||||||
|
<regexpForFailed>.*(<a href=.*a>)</regexpForFailed>
|
||||||
|
<description>こんにちは</description>
|
||||||
|
<descriptionForFailed>さようなら</descriptionForFailed>
|
||||||
|
<setForMatrix>true</setForMatrix>
|
||||||
|
</hudson.plugins.descriptionsetter.DescriptionSetterPublisher>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
7
tests/publishers/fixtures/description-setter002.yaml
Normal file
7
tests/publishers/fixtures/description-setter002.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
publishers:
|
||||||
|
- description-setter:
|
||||||
|
regexp: ".*(<a href=.*a>)"
|
||||||
|
regexp-for-failed: ".*(<a href=.*a>)"
|
||||||
|
description: "こんにちは"
|
||||||
|
description-for-failed: "さようなら"
|
||||||
|
set-for-matrix: true
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<org.jenkinsci.plugins.emotional__jenkins.EmotionalJenkinsPublisher/>
|
<org.jenkinsci.plugins.emotional__jenkins.EmotionalJenkinsPublisher/>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.git.GitPublisher>
|
<hudson.plugins.git.GitPublisher>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<com.cloudbees.jenkins.GitHubCommitNotifier/>
|
<com.cloudbees.jenkins.GitHubCommitNotifier/>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.maven.RedeployPublisher>
|
<hudson.maven.RedeployPublisher>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<au.com.centrumsystems.hudson.plugin.buildpipeline.trigger.BuildPipelineTrigger>
|
<au.com.centrumsystems.hudson.plugin.buildpipeline.trigger.BuildPipelineTrigger>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<au.com.centrumsystems.hudson.plugin.buildpipeline.trigger.BuildPipelineTrigger>
|
<au.com.centrumsystems.hudson.plugin.buildpipeline.trigger.BuildPipelineTrigger>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.plot.PlotPublisher>
|
<hudson.plugins.plot.PlotPublisher>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.plot.PlotPublisher>
|
<hudson.plugins.plot.PlotPublisher>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.plot.PlotPublisher>
|
<hudson.plugins.plot.PlotPublisher>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<be.certipost.hudson.plugin.SCPRepositoryPublisher>
|
<be.certipost.hudson.plugin.SCPRepositoryPublisher>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<org.jenkinsci.plugins.stashNotifier.StashNotifier>
|
<org.jenkinsci.plugins.stashNotifier.StashNotifier>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<xunit>
|
<xunit>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<scm class="hudson.plugins.git.GitSCM">
|
<scm class="hudson.plugins.git.GitSCM">
|
||||||
<configVersion>2</configVersion>
|
<configVersion>2</configVersion>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<scm class="hudson.plugins.git.GitSCM">
|
<scm class="hudson.plugins.git.GitSCM">
|
||||||
<configVersion>2</configVersion>
|
<configVersion>2</configVersion>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<scm class="hudson.plugins.git.GitSCM">
|
<scm class="hudson.plugins.git.GitSCM">
|
||||||
<configVersion>2</configVersion>
|
<configVersion>2</configVersion>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<scm class="hudson.plugins.git.GitSCM">
|
<scm class="hudson.plugins.git.GitSCM">
|
||||||
<configVersion>2</configVersion>
|
<configVersion>2</configVersion>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<scm class="hudson.plugins.repo.RepoScm">
|
<scm class="hudson.plugins.repo.RepoScm">
|
||||||
<manifestRepositoryUrl>https://example.com/project/</manifestRepositoryUrl>
|
<manifestRepositoryUrl>https://example.com/project/</manifestRepositoryUrl>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<triggers class="vector">
|
<triggers class="vector">
|
||||||
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
|
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<triggers class="vector">
|
<triggers class="vector">
|
||||||
<org.jenkinsci.plugins.ghprb.GhprbTrigger>
|
<org.jenkinsci.plugins.ghprb.GhprbTrigger>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<buildWrappers>
|
<buildWrappers>
|
||||||
<hudson.plugins.envfile.EnvFileBuildWrapper>
|
<hudson.plugins.envfile.EnvFileBuildWrapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user