From e1163da30e7c6db6f07b2fba676afe9822882322 Mon Sep 17 00:00:00 2001 From: Olga Lyashevska Date: Thu, 1 Aug 2024 21:40:06 +0200 Subject: [PATCH] Escape quotes in name and description --- copier.yml | 8 -------- template/CITATION.cff.jinja | 4 ++-- template/README.md.jinja | 2 +- template/pyproject.toml.jinja | 4 ++-- template/src/{{package_name}}/__init__.py.jinja | 2 +- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/copier.yml b/copier.yml index 8359c1f1..4bada3f3 100644 --- a/copier.yml +++ b/copier.yml @@ -11,10 +11,6 @@ package_name: package_short_description: type: str default: Short description of package - validator: >- - {% if (package_short_description | regex_replace ('"', '\\\\"')|regex_replace ("'", "\\\\'")%} - package_short_description must not contain unescaped double or single quotes. - {% endif %} keyword1: type: str default: keyword1 @@ -42,10 +38,6 @@ full_name: type: str default: Jane Smith help: Enter your full name. - # validator: >- - # {% if '"' in full_name %} - # full_name must not contain unescaped double quotes. Use \\" for double quotes. - # {% endif %} email: type: str default: yourname@esciencecenter.nl diff --git a/template/CITATION.cff.jinja b/template/CITATION.cff.jinja index c4facdd5..d8cf8a90 100644 --- a/template/CITATION.cff.jinja +++ b/template/CITATION.cff.jinja @@ -4,8 +4,8 @@ cff-version: "1.2.0" title: "{{ package_name }}" authors: - - family-names: {{ full_name.split(' ')[-1] }} - given-names: {{ full_name.split(' ')[0] }} + family-names: {{ full_name.replace('\"', '\\\"').split(' ')[-1] }} + given-names: {{ full_name.replace('\"', '\\\"').split(' ')[0] }} orcid: "https://orcid.org/0000-0000-0000-0000" date-released: 20??-MM-DD doi: diff --git a/template/README.md.jinja b/template/README.md.jinja index 8093442c..04123ae5 100644 --- a/template/README.md.jinja +++ b/template/README.md.jinja @@ -22,7 +22,7 @@ ## How to use {{ package_name }} -{{ package_short_description }} +{{ package_short_description|replace('\"', '\\\"') }} The project setup is documented in [project_setup.md](project_setup.md). Feel free to remove this document (and/or the link to this document) if you don't need it. diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index 4298f46d..0636ce80 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta" [project] authors = [ - { name = "{{ full_name }}", email = "{{ email }}" } + { name = "{{ full_name|replace('\"', '\\\"') }}", email = "{{ email }}" } ] classifiers = [ "Development Status :: 2 - Pre-Alpha", @@ -31,7 +31,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", ] dependencies = [] -description = "{{ package_short_description }}" +description = "{{ package_short_description|replace('\"', '\\\"') }}" keywords = [ "{{ keyword1 }}", "{{ keyword2 }}", diff --git a/template/src/{{package_name}}/__init__.py.jinja b/template/src/{{package_name}}/__init__.py.jinja index 27c656dd..9d801f51 100644 --- a/template/src/{{package_name}}/__init__.py.jinja +++ b/template/src/{{package_name}}/__init__.py.jinja @@ -3,6 +3,6 @@ import logging logging.getLogger(__name__).addHandler(logging.NullHandler()) -__author__ = "{{ full_name }}" +__author__ = "{{ full_name|replace('\"', '\\\"') }}" __email__ = "{{ email }}" __version__ = "{{ version }}"