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

[1876] fix(cookiecutter): Adds XML quote and backslashes escape support #2069

Closed

Conversation

Sharealikelicence
Copy link

Adds XML quote and backslashes escape support

#1876

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@@ -139,6 +139,11 @@ def bool_attr(obj):
"""Render value in XML format appropriate for an attribute."""
return "true" if obj else "false"

def escape_xml(obj):
"""Escapes single quotes and backslashes."""
return obj.replace("\\", "\\\\").replace("'", "\\'")
Copy link

@kesara kesara Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be best way to escape ' and " is using "'" or '"'.

To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character (') may be represented as " ' ", and the double-quote character (") as " " ".
See https://www.w3.org/TR/REC-xml/#syntax

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So best thing to do here might be replacing ' with '.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sharealikelicence
Copy link
Author

Unneeded change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants