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

Disallow extensions with dots, Extension filter checks full extension #2219

Merged
merged 4 commits into from
Nov 23, 2023

Conversation

ItsNiklas
Copy link
Contributor

Description

If the option Filter files passed to compiler by extension list is enabled for a language, only the filename ending with the extension will be checked. This may work for most languages, but can be annoying for e.g. the C language. Files like submission.doc can get through just because they end with a c. This is not the intended behavior of this option. Disabling this option allows the team to fully choose the language.

Honestly, I cannot think of any other case except maybe pyc. But I still think this is a small oversight in the code.

Fixes #2218.

Tested on my local development instance. The behaviour described in the issue is now as expected and I couldn't produce any other new bugs.

Bug fix

Check the extension including the dot in the extension loop. This forces the file to end with exactly .c. The ltrim allows the check to complete even if the extensions are accidentally entered with a dot when creating a new language.

Breaking

If filterCompilerFiles is on:

  • We now assume that the filename contains a dot. I think this is acceptable since this is a contest control system, and this is the expected behavior when this option is enabled by an admin.
    • Maybe change the FILENAME_REGEX to capture this earlier...

@vmcj
Copy link
Member

vmcj commented Nov 19, 2023

Hi @ItsNiklas, thank you for the fix. I'll merge this after one of the others also approves (which will most likely be at/after Friday).

@ItsNiklas ItsNiklas changed the title Extension filter checks full extension, including dot; Fixes #2218 Disallow extensions with dots, Extension filter checks full extension Nov 20, 2023
@ItsNiklas
Copy link
Contributor Author

I added the Assert to the Language entity / form.

image

Had to fix the code that created the delete button because it overode the error message. I added a Doctrine migration because the errors were pretty bad after the entity changed. Hopefully it is correct that way, I wasn't sure.

Thanks

@meisterT meisterT added this pull request to the merge queue Nov 23, 2023
Merged via the queue into DOMjudge:main with commit f866ca5 Nov 23, 2023
18 of 19 checks passed
@ItsNiklas ItsNiklas deleted the fix-langfilter branch November 23, 2023 10:12
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.

doc file can be submitted as a code
4 participants