This is an automated email from the ASF dual-hosted git repository.
uschindler pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 55698aa Fix escaping in playbook/antora templates: Use single quotes
and escape all single quotes by duplicating them (#631)
55698aa is described below
commit 55698aafe4ddca06449eefcc5e751a7899d99311
Author: Uwe Schindler <[email protected]>
AuthorDate: Sun Feb 13 20:19:29 2022 +0100
Fix escaping in playbook/antora templates: Use single quotes and escape all
single quotes by duplicating them (#631)
---
solr/solr-ref-guide/build.gradle | 16 ++++++++++++----
solr/solr-ref-guide/playbook.template.yml | 14 +++++++-------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/solr/solr-ref-guide/build.gradle b/solr/solr-ref-guide/build.gradle
index d349673..1c1f07e 100644
--- a/solr/solr-ref-guide/build.gradle
+++ b/solr/solr-ref-guide/build.gradle
@@ -27,6 +27,14 @@ def officialSiteIncludePrerelease =
propertyOrEnvOrDefault("refguide.official.in
def buildLocalUI = propertyOrEnvOrDefault("refguide.buildLocalUI",
"SOLR_REF_GUIDE_BUILD_LOCAL_UI", "false").toBoolean()
+// This escapes strings inside YAML templates
+// WARNING: Strings in YAML must use single quotes for this to work correctly!
+// Double quotes in YAML can't be used as this requires more complicated
+// escaping, see spec: https://yaml.org/spec/1.2.2/#732-single-quoted-style
+def escapeYamlSingleQuotesString(props) {
+ return props.collectEntries{k, v -> [k, v.toString().replace("'","''")]}
+}
+
// Attach building the ref guide to standard convention tasks. This
// can be optionally turned off (see SOLR-15670).
if (propertyOrEnvOrDefault('refguide.include', 'SOLR_REF_GUIDE_INCLUDE',
"true").toBoolean()) {
@@ -109,7 +117,7 @@ task buildLocalAntoraYaml {
}
into project.ext.antoraConfigBuildDir
- expand(props)
+ expand(escapeYamlSingleQuotesString(props))
}
}
inputs.properties(props)
@@ -136,7 +144,7 @@ task buildLocalAntoraPlaybookYaml(type: Copy) {
'site_dir' : "./" +
file(project.ext.siteStagingDir).relativePath(file(project.ext.siteDir)),
]
- expand(props)
+ expand(escapeYamlSingleQuotesString(props))
inputs.properties(props)
}
@@ -168,7 +176,7 @@ task buildOfficialAntoraPlaybookYaml(type: Copy) {
'site_dir' : "./" +
file(project.ext.playbooksDir).relativePath(file(project.ext.siteDir)),
]
- expand(props)
+ expand(escapeYamlSingleQuotesString(props))
inputs.properties(props)
}
@@ -381,7 +389,7 @@ task buildLocalAntoraSite(type: NpxTask) {
def extraArgs = [
// This attribute should not include ":link", the other 2 should
// This attribute should also not be relative, because it is used in
multiple path directories in the site
- "--attribute",
"page-solr-javadocs=${project(':solr:documentation').docroot.toPath()}",
+ "--attribute",
"page-solr-javadocs=${project(':solr:documentation').docroot.toURI().toASCIIString()}",
"--attribute",
"solr-javadocs=link:../../../${file(project.ext.siteDir).relativePath(project(':solr:documentation').docroot)}",
"--attribute",
"lucene-javadocs=link:../../../${file(project.ext.siteDir).relativePath(project(':solr:documentation').luceneDocsDir)}"
]
diff --git a/solr/solr-ref-guide/playbook.template.yml
b/solr/solr-ref-guide/playbook.template.yml
index a3bf9c8..e4614d6 100644
--- a/solr/solr-ref-guide/playbook.template.yml
+++ b/solr/solr-ref-guide/playbook.template.yml
@@ -10,23 +10,23 @@ urls:
# If this is set to 'httpd', antora will create a .htaccess file with all
redirects, including 'latest'.
# Default is 'static' which produces index.html at the root.
# See https://docs.antora.org/antora/latest/playbook/urls-redirect-facility/
- redirect_facility: ${redirect_facility}
+ redirect_facility: '${redirect_facility}'
content:
# The URL for "Edit this page" links will always go to 'main' in Github
edit_url: '{web_url}/tree/main/{path}'
sources:
- - url: "${source_url}"
- branches: ${source_branches}
- start_path: "${start_path}"
+ - url: '${source_url}'
+ branches: '${source_branches}'
+ start_path: '${start_path}'
ui:
bundle:
- url: "https://nightlies.apache.org/solr/draft-guides/ui-bundle.zip"
+ url: 'https://nightlies.apache.org/solr/draft-guides/ui-bundle.zip'
snapshot: true
- supplemental_files: "${supplemental_files}"
+ supplemental_files: '${supplemental_files}'
output:
clean: true
- dir: "${site_dir}"
+ dir: '${site_dir}'
asciidoc:
attributes:
stem: