Page 1 of 1

Possible to ignore file extension capitalization?

PostPosted:Sun Jan 01, 2017 9:41 pm
by alexwgordon
Hi all,
We're running into the problem of file extensions having different capitalization, i.e. .PDF versus .pdf. Some users have reported issues updating files with different capitalization. Is there a way to ignore the file extension capitalization? Thanks!

Re: Possible to ignore file extension capitalization?

PostPosted:Mon Jan 02, 2017 4:20 pm
by jllort
Which OpenKM version are you using ?

Looking in the source code
Code: Select all
String mimeType = MimeTypeConfig.mimeTypes.getContentType(name.toLowerCase());
Seems the identification of document type is case insensitive. The document name is always converted to lowercase ( all mime types definition provided by default are lowercase ) and then identified. Can you explain with more detail the behaviour, some screenshot is always wellcome for better understanding.

Re: Possible to ignore file extension capitalization?

PostPosted:Tue Jan 03, 2017 3:42 pm
by alexwgordon
Our production instance is Version: 6.3.0 (build: 8156)

I'm verifying with my coworker what he was seeing.

Re: Possible to ignore file extension capitalization?

PostPosted:Tue Jan 03, 2017 6:05 pm
by alexwgordon
Okay so my OKM instance treats files with different file extension capitalization as two different files and won't upload over the other one. I'm running a workflow that checks if a file exists and it currently treats them as different files as well. But the root cause of it is still that my OKM installation doesn't convert to lowercase. Where can change this attribute?

Re: Possible to ignore file extension capitalization?

PostPosted:Wed Jan 04, 2017 11:25 am
by jllort
If I understood you have a file name "name.AAA" yet existing in the OpenKM and as a workflow process step you are trying to upload a file named "name.aaa", then it raises and error, is that ?

If this is your scenario, you can disable the filename check with the Administration > Configuration parameter named
Code: Select all
system.document.name.mismatch.check=false

Re: Possible to ignore file extension capitalization?

PostPosted:Wed Jan 04, 2017 3:20 pm
by alexwgordon
I know this option existed, but can't this potentially create an issue with being able to upload a file with the wrong name entirely, i.e. the wrong file?

Re: Possible to ignore file extension capitalization?

PostPosted:Thu Jan 05, 2017 11:30 am
by jllort
Yes, enabling it solves a kind of problem but can create new ones. The other solution is modifying source code to force all documents name be lowercase. I can guide about how doing it.

Re: Possible to ignore file extension capitalization?

PostPosted:Thu Jan 05, 2017 3:04 pm
by alexwgordon
Yeah that'd be great if we could do that! Well actually I think I can figure it out by modifying the vernum for all new files, but is there an "easy" way to do it for existing files?

Re: Possible to ignore file extension capitalization?

PostPosted:Fri Jan 06, 2017 12:10 pm
by jllort
Have two options:
Take a look at DbDocumentModule.java ( see create, rename and update , line 95, 331, 828)

Probably the easiest is modify PahtUtils class the method named escape:
Code: Select all
public static String escape(String name) {
		String ret = cleanup(name);

		// Fix XSS issues
		ret = Encode.forHtml(ret);

		return ret.toLoweCase();
	}
The problem is the method espace is executed from a lot of places, for example, creating folder etc... here you are forcing a lot of things to being lowercase.

If you do not have portable developement environment you can download from here https://sourceforge.net/projects/openkmportabledev/