You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: Ability to serialize malformed token stream #292
We have a use case that requires the ability to re-serialize malformed html input without needing to insert extra open tags to appease the Serializer, which panics when it tries to serialize a close tag when the stack is empty.
The obvious (naive perhaps?) solution is to provide a mechanism to manipulate the stack in order to fake the presence of an open tag. Alternatively, the behavior could be changed in the parent and end_elem methods to not panic in the absence of an ElemInfo on the stack, and to instead either create or return a sane default. I'll start working on it from that angle, but I'm open to alternative approaches.
On further inspection, the stack that's causing me so much headache is only in the html5ever implementation of the Serializer trait, which doesn't have any notion of a stack. So now I'm thinking it's likely a mistake to expose it through that interface since there may not even be a stack behind the scenes.
@jechas01 Could you elaborate a bit more? What do you mean by re-serialize? You serialize, parse and then serialize again? Do you do modifications during tokenization/treebuilding that aren't in HTML5 spec?
We tokenize input which may or may not be valid/complete, do some modifications such as removing tags or attributes, and then re-serialize whatever is left. None of our processing will make the html invalid per the HTML5 spec, but it may come to us that way.
Sorry, should have linked back to the PR that spawned this issue, #277
changed the title [-]Feature request: API to manipulate the Serializer stack[/-][+]Feature request: Ability to serialize malformed token stream[/+]on Aug 2, 2017
Activity
jrobsonchase commentedon Aug 1, 2017
On further inspection, the stack that's causing me so much headache is only in the html5ever implementation of the Serializer trait, which doesn't have any notion of a stack. So now I'm thinking it's likely a mistake to expose it through that interface since there may not even be a stack behind the scenes.
Ygg01 commentedon Aug 2, 2017
@jechas01 Could you elaborate a bit more? What do you mean by
re-serialize? You serialize, parse and then serialize again? Do you do modifications during tokenization/treebuilding that aren't in HTML5 spec?jrobsonchase commentedon Aug 2, 2017
We tokenize input which may or may not be valid/complete, do some modifications such as removing tags or attributes, and then re-serialize whatever is left. None of our processing will make the html invalid per the HTML5 spec, but it may come to us that way.
Sorry, should have linked back to the PR that spawned this issue, #277
[-]Feature request: API to manipulate the Serializer stack[/-][+]Feature request: Ability to serialize malformed token stream[/+]Auto merge of #293 - jechas01:no_stack_panics, r=jdm