artefactual-labs / ansible-atom

An ansible role for deploying AtoM
GNU Affero General Public License v3.0
6 stars 5 forks source link

Problem: Role fails when using special chars in `atom_title` and `atom_description` #106

Open mamedin opened 3 years ago

mamedin commented 3 years ago

For instance, when using:

atom_description: "Fonds d'archives de la Ville de XXXX"

Error when purging the database:

TASK [artefactual.atom : Purge database] *************************************************************************************************************************************************************************************************************************************************
Wednesday 22 September 2021  13:17:52 +0200 (0:00:00.043)       0:04:50.129 *** 
fatal: [XXXXX-nginx]: FAILED! => {"changed": true, "cmd": "php -d memory_limit=-1 symfony tools:purge --no-confirmation --email='support@artefactual.com' --username='support' --password='YYYYYYY' --title='Archives de XXXXXXX' --description='Fonds d'archives de la Ville de XXXXXX' --url='http://127.0.0.1'", "delta": "0:00:00.001963", "end": "2021-09-22 11:17:53.171412", "msg": "non-zero return code", "rc": 2, "start": "2021-09-22 11:17:53.169449", "stderr": "/bin/sh: 1: Syntax error: Unterminated quoted string", "stderr_lines": ["/bin/sh: 1: Syntax error: Unterminated quoted string"], "stdout": "", "stdout_lines": []}
mamedin commented 3 years ago

As first try I tested using the jinja2 escape or urlencode filters at:

https://github.com/artefactual-labs/ansible-atom/blob/master/tasks/flush.yml#L12

For instance:

shell: "php -d memory_limit=-1 symfony tools:purge --no-confirmation --email='{{ atom_user_email }}' --username='{{ atom_user_username }}' --password='{{ atom_user_password }}' --title='{{ atom_title | escape }}' --description='{{ atom_description | escape }}' --url='http://127.0.0.1'"
mamedin commented 3 years ago

It seems a better alternative, at least for the example in this issue:

shell: "php -d memory_limit=-1 symfony tools:purge --no-confirmation --email='{{ atom_user_email }}' --username='{{ atom_user_username }}' --password='{{ atom_user_password }}' --title=\"{{ atom_title }}\" --description=\"{{ atom_description }}\" --url='http://127.0.0.1'"