Possible to ignore file extension capitalization?

We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules
Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
Post Reply
alexwgordon
Gold Boarder
Gold Boarder
Posts: 182
Joined: Fri Sep 05, 2014 6:24 pm

Possible to ignore file extension capitalization?

Post by alexwgordon » Sun Jan 01, 2017 9:41 pm

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!

jllort
Moderator
Moderator
Posts: 10830
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Possible to ignore file extension capitalization?

Post by jllort » Mon Jan 02, 2017 4:20 pm

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.

alexwgordon
Gold Boarder
Gold Boarder
Posts: 182
Joined: Fri Sep 05, 2014 6:24 pm

Re: Possible to ignore file extension capitalization?

Post by alexwgordon » Tue Jan 03, 2017 3:42 pm

Our production instance is Version: 6.3.0 (build: 8156)

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

alexwgordon
Gold Boarder
Gold Boarder
Posts: 182
Joined: Fri Sep 05, 2014 6:24 pm

Re: Possible to ignore file extension capitalization?

Post by alexwgordon » Tue Jan 03, 2017 6:05 pm

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?

jllort
Moderator
Moderator
Posts: 10830
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Possible to ignore file extension capitalization?

Post by jllort » Wed Jan 04, 2017 11:25 am

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

alexwgordon
Gold Boarder
Gold Boarder
Posts: 182
Joined: Fri Sep 05, 2014 6:24 pm

Re: Possible to ignore file extension capitalization?

Post by alexwgordon » Wed Jan 04, 2017 3:20 pm

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?

jllort
Moderator
Moderator
Posts: 10830
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Possible to ignore file extension capitalization?

Post by jllort » Thu Jan 05, 2017 11:30 am

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.

alexwgordon
Gold Boarder
Gold Boarder
Posts: 182
Joined: Fri Sep 05, 2014 6:24 pm

Re: Possible to ignore file extension capitalization?

Post by alexwgordon » Thu Jan 05, 2017 3:04 pm

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?

jllort
Moderator
Moderator
Posts: 10830
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Possible to ignore file extension capitalization?

Post by jllort » Fri Jan 06, 2017 12:10 pm

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/

Post Reply