Accept property for FileUploadField not working for .docx extension

Dear CUBA community,

I am trying to get an upload button that allows .docx files and .pdf files to be selected in the file selection dialog. However, when I use the ‘accept’ XML attribute for a FileUploadField (set to *.pdf,*.docx) to specify these extensions or the corresponding Java method, the file selection dialog only allows pdf files to be selected. When setting the field to just *.docx, no extension filtering is performed at all. Expected behaviour happens when setting it to e.g. *.pdf or *.xml.

How can I get this functionality working for .docx files?


To reproduce:

<vbox spacing="true">
	<upload accept="*.pdf" uploadButtonCaption=".pdf (works)"/>
	<upload accept="*.xml" uploadButtonCaption=".xml (works)"/>
	<upload accept="*.pdf,*.xml" uploadButtonCaption=".pdf and .xml (works)"/>
	<upload accept="*.docx" uploadButtonCaption=".docx (does not work)"/>
	<upload accept="*.pdf,*.docx" uploadButtonCaption=".pdf and .docx (does not work)"/>
</vbox>

I managed to get it working with the following code that uses Java reflection:

@Inject
protected FileUploadField documentUpload;

[..]

try {
	Field field = WebFileUploadField.class.getDeclaredField("uploadButton");
	field.setAccessible(true);
	CubaFileUpload fileUpload = (CubaFileUpload) field.get(documentUpload);
	fileUpload.setAccept(".pdf,.docx");
} catch (NoSuchFieldException | IllegalAccessException e) {
	throw new RuntimeException(e);
}