diff options
author | Jan Hruban <jan.hruban@gooddata.com> | 2018-01-08 17:11:49 +0100 |
---|---|---|
committer | Jan Hruban <jan.hruban@gooddata.com> | 2018-01-16 16:08:41 +0100 |
commit | 30fe5dae985644126e4832a3bd60178e98594abb (patch) | |
tree | 6fde83e1b0536aa103afc8dfc563a1ea4c8ce706 /tests/yamlparser/fixtures/variable_escaping.xml | |
parent | 705051658fabb8c0e92cd8dbad87015dfdda7f9f (diff) | |
download | python-jenkins-job-builder-30fe5dae985644126e4832a3bd60178e98594abb.tar.gz python-jenkins-job-builder-30fe5dae985644126e4832a3bd60178e98594abb.tar.xz python-jenkins-job-builder-30fe5dae985644126e4832a3bd60178e98594abb.zip |
Fix the formatter regex
Before:
{{var}} -> {var}, but the regex matches at the inner brace, but
re_replace returns the whole match (match.group(0) = "{var}") unchanged, passing
"{{var}}" to Formatter.
{{defined_var|def}} -> {{defined_var}}, because the regex matches at the
inner brace and re_replace returns "{%s}" % key ("{defined_var}"), passing just
"{{defined_var}}" to Formatter.
{{undefined_var|def}} -> exception, because the regex again matches at
the inner brace and re_replace returns default ("def"), passing "{def}"
to Formatter which then fails as def is not a defined variable (assuming
it isn't and allow_empty = False).
{{undefined_var|defined_var}} -> value of defined_var, same as above,
"{defined_var}" is passed to Formatter.
By preventing the regex from matching at inner braces, none of these
weird cases happen and even-braced strings are passed to Formatter
unmodified.
Change-Id: I8a74f9b4236ca7bcc72dd207fca23c2bf6a7c801
Co-Authored-By: Tomáš Janoušek <tomas.janousek@gooddata.com>
Diffstat (limited to 'tests/yamlparser/fixtures/variable_escaping.xml')
-rw-r--r-- | tests/yamlparser/fixtures/variable_escaping.xml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/yamlparser/fixtures/variable_escaping.xml b/tests/yamlparser/fixtures/variable_escaping.xml new file mode 100644 index 00000000..16a37dd2 --- /dev/null +++ b/tests/yamlparser/fixtures/variable_escaping.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <actions/> + <description><!-- Managed by Jenkins Job Builder --></description> + <keepDependencies>false</keepDependencies> + <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> + <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> + <concurrentBuild>false</concurrentBuild> + <canRoam>true</canRoam> + <properties/> + <scm class="hudson.scm.NullSCM"/> + <builders> + <hudson.tasks.Shell> + <command>echo "{var}" +echo "{defined_var|def}" +echo "{undefined_var|def}" +echo "{undefined_var|defined_var}" +</command> + </hudson.tasks.Shell> + </builders> + <publishers/> + <buildWrappers/> +</project> |