DOMjudge / domjudge

DOMjudge programming contest jury system
https://www.domjudge.org
GNU General Public License v2.0
732 stars 256 forks source link

`doc` file can be submitted as a code #2218

Closed HeRaNO closed 11 months ago

HeRaNO commented 11 months ago

Description of the problem

doc file can be submitted as code. It seems the file bypasses the file extension check.

Your environment

Steps to reproduce

A.zip

Unzip the archive first, and submit the A.doc to any problem. Language setting sets as default.

setting

Expected behaviour

expect

Actual behaviour

actual

backend

vmcj commented 11 months ago

Hi @HeRaNO, I've tried to reproduce this and I can't. Can you maybe upload a bit more screenshots on how you submit this?

When I upload a file ending with the .doc syntax via submit the following field will stay empty: Language but for you this got picked up as C? Or did you manually select C as language?

If it's the first case this is indeed a bug, in the second case the message match any of the allowed extensions would be wrong as a participant can decide to hand something in with a custom extension (think about someone who can decide to use .py2 vs .py3) and the system should just leave the language selection to the team IMO.

ItsNiklas commented 11 months ago

I think the problem is that when the option Filter files passed to compiler by extension list is enabled, the system only checks if the filename ends with 'c', which is the case for .doc. Uploading any other file, e.g. .pdf and selecting C as language will fail with the expected behavior described above. This has nothing to do with custom extensions and language selection, I think.

Of course, the user has to select the Language C manually, but the filter should step in (only if the option is activated). I agree that this should be expected behaviour.

The filter algorithm linked above is probably not perfect in this sense.

HeRaNO commented 11 months ago

Hi @HeRaNO, I've tried to reproduce this and I can't. Can you maybe upload a bit more screenshots on how you submit this?

When I upload a file ending with the .doc syntax via submit the following field will stay empty: Language but for you this got picked up as C? Or did you manually select C as language?

If it's the first case this is indeed a bug, in the second case the message match any of the allowed extensions would be wrong as a participant can decide to hand something in with a custom extension (think about someone who can decide to use .py2 vs .py3) and the system should just leave the language selection to the team IMO.

Hi and yes, it's the second case. The participant manually selects C language.

So the extension filter does not mean to must submit files among these extensions, it's only used to infer the language that participants use? Maybe I have some misunderstanding about it.

ItsNiklas commented 11 months ago

Hi @HeRaNO, I've tried to reproduce this and I can't. Can you maybe upload a bit more screenshots on how you submit this? When I upload a file ending with the .doc syntax via submit the following field will stay empty: Language but for you this got picked up as C? Or did you manually select C as language? If it's the first case this is indeed a bug, in the second case the message match any of the allowed extensions would be wrong as a participant can decide to hand something in with a custom extension (think about someone who can decide to use .py2 vs .py3) and the system should just leave the language selection to the team IMO.

Hi and yes, it's the second case. The participant manually selects C language.

So the extension filter does not mean to must submit files among these extensions, it's only used to infer the language that participants use? Maybe I have some misunderstanding about it.

No, you are right: Enabling the filter should result in must submit files among these extensions. Language inference is always used.

There is just a small oversight in the code. I think I can work on fixing it.

HeRaNO commented 11 months ago

Hi @HeRaNO, I've tried to reproduce this and I can't. Can you maybe upload a bit more screenshots on how you submit this? When I upload a file ending with the .doc syntax via submit the following field will stay empty: Language but for you this got picked up as C? Or did you manually select C as language? If it's the first case this is indeed a bug, in the second case the message match any of the allowed extensions would be wrong as a participant can decide to hand something in with a custom extension (think about someone who can decide to use .py2 vs .py3) and the system should just leave the language selection to the team IMO.

Hi and yes, it's the second case. The participant manually selects C language. So the extension filter does not mean to must submit files among these extensions, it's only used to infer the language that participants use? Maybe I have some misunderstanding about it.

No, you are right: Enabling the filter should result in must submit files among these extensions. Language inference is always used.

There is just a small oversight in the code. I think I can work on fixing it.

OK I got that. Thank you. 👍