-
Notifications
You must be signed in to change notification settings - Fork 4
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
Attempt to fix string escaping and template problems. #25
Conversation
Ok I just did some testing on a random website HTML file (30kb). Edit: As the file is 30kb and it doesn't seem to take considerably longer to process than before, i don't think there is any big performance impact with this. Edit: My testing is inaccurate |
SO post. In general, it should be escaped as well, but i'm afraid we won't be able to use |
Ah so its like a comment but part of the document. That's weird |
4a4b253
to
d611215
Compare
So i believe i fixed the problems my format function had before, but i don't know if it's really that much better to use a whole custom non-recursive string formatter instead of just concatenating the strings. I'm also unsure about what exactly |
Reading up on that, according to the specification explained in this SO answer, you can have anything in a CDATA block without it getting parsed, except its end sequence. The end sequence cannot be escaped, anything else doesn't need escaping. That's how I understand it. |
I don't remember saying that i was against concatenating method specifically 🤔 If you could re-do this with concatenation instead, it would be much appreciated (and more concise as well).
It turns e.g. |
If we really want to, we can do what's suggested in this answer. |
😐? if self.standalone:
return "<" + self.name + attribute_string + "/>"
else:
return "".join([
"<" + self.name + attribute_string + ">",
self.content.xml_escape() + cdata_string + children_string,
"</" + self.name + ">"
]) |
I meant that as in "more concise than the 'escaper' you currently have". Additionally, you can use parentheses instead of |
d611215
to
03b68a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, sorry for the review taking so long and thanks for contributing!
If you mean that when e.g. |
You added xml_unescape but Godot xml parser already does unecaping. func test_unescaping() -> void:
var xml := XMLNode.new()
xml.content = """
xml.attributes["one"] = "<"
xml.attributes["two"] = "& "
var parsed_xml := XML.parse_str(xml.dump_str(true)).root
# This is a function i wrote that uses GDUnit to test if all properties match (It will fail in this case)
assert_xml(xml, parsed_xml) |
Fix #23
I don't know exactly what cdata is. Should it be escaped too?
I'm a bit concerned about the performance impact of the weird template formatter i made.
I made it because it's way cleaner to work with templates obviously and it would be ugly to switch it all to concatenating.
In my testing it seemed to solve the problem though.