Skip to content

escape strings for xml #1

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

dethrophes
Copy link

Rules like the following break the dot xml format.
-A PREROUTING -m u32 --u32 "0x6>>0x18=0x6" -j ACCEPT

@@ -45,30 +45,43 @@ def get_node_name(table_name, chain_name):
def get_port_name(rule_index):
return "rule_" + str(rule_index)


xml_esc = {
re.compile('&') : '&' ,
Copy link

Choose a reason for hiding this comment

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

How about over-long characters in UTF-8 and <![CDATA[ for XHTML? I think, better to use ready to use library than trying to escape only limited set of characters by handwritten code. Moreover, substitution by multiple regular expressions is very ineffective (as same symbol in each line must be reviewed multiple times). And such approach is error-prone, as the whole result depend on the orded in which you are applying substitutions. You can construct a single regular expression for this.

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