Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Description special characters issue vol. 2.0 #56

Open
przemkalit opened this issue Jan 8, 2025 · 3 comments
Open

Description special characters issue vol. 2.0 #56

przemkalit opened this issue Jan 8, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@przemkalit
Copy link
Contributor

przemkalit commented Jan 8, 2025

Summary

Hey,
I am going back to the PR that I've created here, the issue is still occurs, what I've did not notice that filetree_read is ignoring files that are not valid yaml files.

I have two resolution:

  1. the one that I proposed in that PR.
  2. swaping " to '.

If you guys have other idea, please let me know.

Issue Type

  • Bug Report

Ansible, Collection, Controller details

N/A

OS / ENVIRONMENT

N/A

Desired Behavior

Yaml files are properly exported.

Actual Behavior

Yaml file is not properly formated due to not escaped special characters.

STEPS TO REPRODUCE

  1. Create job template with description: XXX "report" \\10.10.10.128\something$\whatever\yyy\zzz.
  2. Export Job templates with filetree_create.
  3. Use filetree_read to load the file.
@przemkalit przemkalit added the bug Something isn't working label Jan 8, 2025
@ivarmu
Copy link
Contributor

ivarmu commented Jan 13, 2025

Swapping " to ' should work ok, but the description can contain ' character as well and will cause the same result than with ".

How about doing the same as with question_description?

{% if survey_item_content.key | regex_search('question_description|default') %}
{% set current_content = survey_item_content.key + ': !unsafe "' + (survey_item_content.value | regex_replace("\n", "\\\\n") | regex_replace('"', '\\"')) + '"' %}

@przemkalit
Copy link
Contributor Author

przemkalit commented Jan 20, 2025

I've tested you proposal, but there are still issues with backslashes, I believe it would be simpler to escape ' than escaping everything that could be problematic.

@przemkalit
Copy link
Contributor Author

I've tested escaping the ', and it would look like below:

    description: '{{ template_overrides_resources.workflow_job_template[current_workflow_job_templates_asset_value.name].description
                     | default(template_overrides_global.workflow_template.description)
                     | default(current_workflow_job_templates_asset_value.description | replace("'","''")) }}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants