jmix icon indicating copy to clipboard operation
jmix copied to clipboard

WebDAV: URISyntaxException in case of file with non-standard space symbol in name

Open dtaimanov opened this issue 2 years ago • 5 comments

  1. Open WebDAV documents view
  2. Try to upload file The_document with_long_name_and_no_spaces — копия.txt as new WebDAV document (I hope original symbols of the file name will be preserved for uploaded instance). ER: file uploaded without issues AR:
java.net.URISyntaxException: Illegal character in path at index 44: /The_document%20with_long_name_and_no_spaces —%20копия.txt
	at java.base/java.net.URI$Parser.fail(URI.java:2974)
	at java.base/java.net.URI$Parser.checkChars(URI.java:3145)
	at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3227)
	at java.base/java.net.URI$Parser.parse(URI.java:3186)
	at java.base/java.net.URI.<init>(URI.java:623)
	at io.jmix.webdav.listener.WebdavDocumentEventListener.buildFullPath(WebdavDocumentEventListener.java:172)
	at io.jmix.webdav.listener.WebdavDocumentEventListener.onWebdavDocumentSaving(WebdavDocumentEventListener.java:73)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:348)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:233)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:174)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:145)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:437)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:370)
	at io.jmix.data.impl.EntityEventManager.publishEntitySavingEvent(EntityEventManager.java:42)
	at io.jmix.eclipselink.impl.JpaDataStore.saveAll(JpaDataStore.java:288)
	at io.jmix.core.datastore.AbstractDataStore.save(AbstractDataStore.java:221)
	at io.jmix.eclipselink.impl.JpaDataStore.save(JpaDataStore.java:227)
	at io.jmix.core.impl.UnconstrainedDataManagerImpl.saveContextToStore(UnconstrainedDataManagerImpl.java:257)
	at io.jmix.core.impl.UnconstrainedDataManagerImpl.save(UnconstrainedDataManagerImpl.java:216)
	at io.jmix.webdav.service.impl.WebdavDocumentsManagementServiceImpl.createVersioningDocumentByFileRef(WebdavDocumentsManagementServiceImpl.java:694)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:699)
	at io.jmix.webdav.service.impl.WebdavDocumentsManagementServiceImpl$$SpringCGLIB$$0.createVersioningDocumentByFileRef(<generated>)
	at io.jmix.webdavflowui.view.webdavdocument.WebdavDocumentListView.createWebdavDocument(WebdavDocumentListView.java:358)
	at io.jmix.webdavflowui.view.webdavdocument.WebdavDocumentListView.onFileUploadSucceed(WebdavDocumentListView.java:349)
        ...

dtaimanov avatar Oct 24 '23 19:10 dtaimanov

Actually I wasn't able to reproduce this. The file you provided is downloaded without extra symbols, but I also tried to copy it name from text and paste as target file name. As the result in any combinations I tried the file was uploaded and downloaded just fine.

Can you please provide it packed with WinRAR or give some more details to reproduce in case you used some exotic browser versions or something ?

syncro avatar Jan 17 '24 07:01 syncro

See io.jmix.webdav.tools.WebdavResourceUriTools#encodeSpaces method, not only 20-th symbol of unicode should be escaped but other space-symbols too.

The_document with_long_name_and_no_spaces — копия.txt.zip

dtaimanov avatar Jan 17 '24 08:01 dtaimanov

the bug and fix are finely reproduced when the file is taken from zip

syncro avatar Jan 17 '24 09:01 syncro

Postpone this issue until https://github.com/jmix-framework/jmix/issues/2003 is done or cancelled.

Gavrilov-Ivan avatar Feb 12 '24 12:02 Gavrilov-Ivan

On hold due to overall issue with escaping - can't be fully fixed without massive rework/backward compatibility breakage. Current case is very niche - postponed until more common issue scenario is occurred.

Gavrilov-Ivan avatar Sep 25 '24 12:09 Gavrilov-Ivan