Skip to content

Conversation

@catatonicprime
Copy link
Contributor

@catatonicprime catatonicprime commented Dec 30, 2020

Discovered this issue while fuzzing a parser I've been working on. When a scoped directive's closing tag is malformed with whitespace/newlines prior to the '>' this will generate an error during httpd's config test.

e.g.

<VirtualHost "test"
</VirtualHost
>

or

<VirtualHost "test"
</VirtualHost >

Will cause this error:

httpd: Syntax error on line 2 of /usr/local/apache2/conf/httpd.conf: </VirtualHost> directive missing closing '>'

This patch aligns the token stream to more accurately detect this error. I identify open tags vs. closing tags by the absence or presence of the '/' after the '<', respectively. The opening tags should maintain all previous functionality. The closing tags will now be restricted to non-whitespace characters within.

I've included a positive test and negative test related to this specific issue. The negative test (test_malformed_scoped_directive_closing_tag) token stream was derived after the patches. The positive test (test_normal_scoped_directive) is present to ensure expected functionality is maintained.

@Anteru Anteru self-assigned this Jan 6, 2021
@Anteru Anteru added this to the 2.7.4 milestone Jan 6, 2021
@Anteru Anteru added the changelog-update Items which need to get mentioned in the changelog label Jan 6, 2021
@Anteru Anteru merged commit effe7c3 into pygments:master Jan 6, 2021
@Anteru
Copy link
Collaborator

Anteru commented Jan 6, 2021

Merged, thanks!

@Anteru Anteru removed the changelog-update Items which need to get mentioned in the changelog label Jan 6, 2021
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