[jira] [Commented] (VFS-790) VFS2 handles files with special characters incorrectly

2020-12-08 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-790?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17246135#comment-17246135
 ] 

Gary D. Gregory commented on VFS-790:
-

[~vnashkev]
Feel free to provide a PR so we can see what you are proposing. However, it is 
not clear to me that VFS should sanitize any input. Let's see if there are 
other opinions. 


> VFS2 handles files with special characters incorrectly
> --
>
> Key: VFS-790
> URL: https://issues.apache.org/jira/browse/VFS-790
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.2, 2.7.0
> Environment: windows 10
> java 8
> vfs 2.7
>Reporter: Vitali Nashkevich
>Priority: Major
> Attachments: LocalFileProviderTest.java
>
>
> The following Testcase fails :
>  
> {code:java}
> @Test
> public final static void testLocalFile() 
>   throws Exception
> {
>   final String prefix = new String(new char[] { '\u0074', '\u0065', 
> '\u00a0', '\u0074' });
>   final File f = File.createTempFile(prefix + "-" , "-" + prefix);
>   assert f.exists();
>   
>   final URI uri = f.toURI();
>   
>   try ( final FileSystemManager m = VFS.getManager() )
>   {
>   try ( final FileObject s = m.resolveFile(uri) )
>   {
>   try ( final FileContent sourceContent = s.getContent() )
>   {
>   final long size = sourceContent.getSize();
>   assert size==f.length();
>   }
>   }
>   }   
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (VFS-790) VFS2 handles files with special characters incorrectly

2020-12-07 Thread Vitali Nashkevich (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-790?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17245154#comment-17245154
 ] 

Vitali Nashkevich commented on VFS-790:
---

Another interesting link 
[|[https://en.wikipedia.org/wiki/Internationalized_Resource_Identifierhttp://example.com|https://en.wikipedia.org/wiki/Internationalized_Resource_Identifier]]

> VFS2 handles files with special characters incorrectly
> --
>
> Key: VFS-790
> URL: https://issues.apache.org/jira/browse/VFS-790
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.2, 2.7.0
> Environment: windows 10
> java 8
> vfs 2.7
>Reporter: Vitali Nashkevich
>Priority: Major
> Attachments: LocalFileProviderTest.java
>
>
> The following Testcase fails :
>  
> {code:java}
> @Test
> public final static void testLocalFile() 
>   throws Exception
> {
>   final String prefix = new String(new char[] { '\u0074', '\u0065', 
> '\u00a0', '\u0074' });
>   final File f = File.createTempFile(prefix + "-" , "-" + prefix);
>   assert f.exists();
>   
>   final URI uri = f.toURI();
>   
>   try ( final FileSystemManager m = VFS.getManager() )
>   {
>   try ( final FileObject s = m.resolveFile(uri) )
>   {
>   try ( final FileContent sourceContent = s.getContent() )
>   {
>   final long size = sourceContent.getSize();
>   assert size==f.length();
>   }
>   }
>   }   
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (VFS-790) VFS2 handles files with special characters incorrectly

2020-12-07 Thread Vitali Nashkevich (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-790?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17245149#comment-17245149
 ] 

Vitali Nashkevich commented on VFS-790:
---

Thanks a lot for your attention,

I think VFS must be conform to JDK URI class regardless of RIGHT-definition.
 As several sources ( [https://www.w3.org/International/O-URL-code.html], 
[https://en.wikipedia.org/wiki/Percent-encoding] ) suggest that
 java character '\u00a0' must be
 # converted to 0xC2A0 UTF-8 character and then
 # encoded to '%C2%A0' URI-fragment

Many online URI-encoders works this way. 
([https://meyerweb.com/eric/tools/dencoder/]).
 Java URI does the same as well.

VFS decodes '%C2%A0' sequence into 2-characters string

{ '\u00C2', '\u00A0' }

instead of 1-character string

{ '\u00A0'}

.

> VFS2 handles files with special characters incorrectly
> --
>
> Key: VFS-790
> URL: https://issues.apache.org/jira/browse/VFS-790
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.2, 2.7.0
> Environment: windows 10
> java 8
> vfs 2.7
>Reporter: Vitali Nashkevich
>Priority: Major
> Attachments: LocalFileProviderTest.java
>
>
> The following Testcase fails :
>  
> {code:java}
> @Test
> public final static void testLocalFile() 
>   throws Exception
> {
>   final String prefix = new String(new char[] { '\u0074', '\u0065', 
> '\u00a0', '\u0074' });
>   final File f = File.createTempFile(prefix + "-" , "-" + prefix);
>   assert f.exists();
>   
>   final URI uri = f.toURI();
>   
>   try ( final FileSystemManager m = VFS.getManager() )
>   {
>   try ( final FileObject s = m.resolveFile(uri) )
>   {
>   try ( final FileContent sourceContent = s.getContent() )
>   {
>   final long size = sourceContent.getSize();
>   assert size==f.length();
>   }
>   }
>   }   
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (VFS-790) VFS2 handles files with special characters incorrectly

2020-12-05 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-790?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17244514#comment-17244514
 ] 

Gary D. Gregory commented on VFS-790:
-

[~vnashkev]

I added a different version of this test case here: 
{{org.apache.commons.vfs2.provider.local.test.FileNameTests.testLocalFile()}}

Note that the above new test method creates a legal URI, it does not contain a 
NB-SP char (0xA0).

Sadly, the URI class lets you create URIs with paths which contains character 
that are not escaped which end up causing havoc later when you try to use them 
as actual legal URIs when in fact they are not.

The bottom line is that one must sanitize URI input before creating them.

 

> VFS2 handles files with special characters incorrectly
> --
>
> Key: VFS-790
> URL: https://issues.apache.org/jira/browse/VFS-790
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.2, 2.7.0
> Environment: windows 10
> java 8
> vfs 2.7
>Reporter: Vitali Nashkevich
>Priority: Major
> Attachments: LocalFileProviderTest.java
>
>
> The following Testcase fails :
>  
> {code:java}
> @Test
> public final static void testLocalFile() 
>   throws Exception
> {
>   final String prefix = new String(new char[] { '\u0074', '\u0065', 
> '\u00a0', '\u0074' });
>   final File f = File.createTempFile(prefix + "-" , "-" + prefix);
>   assert f.exists();
>   
>   final URI uri = f.toURI();
>   
>   try ( final FileSystemManager m = VFS.getManager() )
>   {
>   try ( final FileObject s = m.resolveFile(uri) )
>   {
>   try ( final FileContent sourceContent = s.getContent() )
>   {
>   final long size = sourceContent.getSize();
>   assert size==f.length();
>   }
>   }
>   }   
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (VFS-790) VFS2 handles files with special characters incorrectly

2020-12-04 Thread Vitali Nashkevich (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-790?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17243835#comment-17243835
 ] 

Vitali Nashkevich commented on VFS-790:
---


{noformat}
org.apache.commons.vfs2.FileSystemException: Could not determine the size of 
"file:///C:/Users/NASHKE~1/AppData/Local/Temp/te t-7766545175922765294-te t" 
because it is not a file.
at 
org.apache.commons.vfs2.provider.DefaultFileContent.getSize(DefaultFileContent.java:125)
at LocalFileProviderTest.testLocalFile(LocalFileProviderTest.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at 
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:571)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:707)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:979)
at 
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
at org.testng.TestNG.runSuites(TestNG.java:1028)
at org.testng.TestNG.run(TestNG.java:996)
at 
org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

{noformat}


> VFS2 handles files with special characters incorrectly
> --
>
> Key: VFS-790
> URL: https://issues.apache.org/jira/browse/VFS-790
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.2, 2.7.0
> Environment: windows 10
> java 8
> vfs 2.7
>Reporter: Vitali Nashkevich
>Priority: Major
> Attachments: LocalFileProviderTest.java
>
>
> The following Testcase fails :
>  
> {code:java}
> @Test
> public final static void testLocalFile() 
>   throws Exception
> {
>   final String prefix = new String(new char[] { '\u0074', '\u0065', 
> '\u00a0', '\u0074' });
>   final File f = File.createTempFile(prefix + "-" , "-" + prefix);
>   assert f.exists();
>   
>   final URI uri = f.toURI();
>   
>   try ( final FileSystemManager m = VFS.getManager() )
>   {
>   try ( final FileObject s = m.resolveFile(uri) )
>   {
>   try ( final FileContent sourceContent = s.getContent() )
>   {
>   final long size = sourceContent.getSize();
>   assert size==f.length();
>   }
>   }
>   }   
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (VFS-790) VFS2 handles files with special characters incorrectly

2020-12-03 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-790?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17243557#comment-17243557
 ] 

Gary D. Gregory commented on VFS-790:
-

Please show the failure in your description. 

> VFS2 handles files with special characters incorrectly
> --
>
> Key: VFS-790
> URL: https://issues.apache.org/jira/browse/VFS-790
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.2, 2.7.0
> Environment: windows 10
> java 8
> vfs 2.7
>Reporter: Vitali Nashkevich
>Priority: Major
> Attachments: LocalFileProviderTest.java
>
>
> The following Testcase fails :
>  
> {code:java}
> @Test
> public final static void testLocalFile() 
>   throws Exception
> {
>   final String prefix = new String(new char[] { '\u0074', '\u0065', 
> '\u00a0', '\u0074' });
>   final File f = File.createTempFile(prefix + "-" , "-" + prefix);
>   assert f.exists();
>   
>   final URI uri = f.toURI();
>   
>   try ( final FileSystemManager m = VFS.getManager() )
>   {
>   try ( final FileObject s = m.resolveFile(uri) )
>   {
>   try ( final FileContent sourceContent = s.getContent() )
>   {
>   final long size = sourceContent.getSize();
>   assert size==f.length();
>   }
>   }
>   }   
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)