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

Detect malformed closing tags as errors in ApacheConfLexer #1656

Merged
merged 1 commit into from Jan 6, 2021

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 merged commit effe7c3 into pygments:master Jan 6, 2021
13 checks passed
@Anteru
Copy link
Collaborator

@Anteru Anteru commented Jan 6, 2021

Merged, thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants