6 Replies Latest reply on Nov 7, 2008 10:46 AM by Ales Justin

    ".folderName" leads to IllegalArgumentException

    Andrew Rubinger Master

      I've got a failing case on my Hudson:

      java.lang.IllegalArgumentException: Illegal token in path: /home/deployer/.hudson/jobs/AS_TestSuite_Smoke_Tests/workspace/trunk/build/output/jboss-5.0.0.GA/lib/jboss-deployers-core-spi.jar/


      ...due to the ".hudson" directory.

      Carlo points out failing test cases in VFS: http://wolf.nerdnet.nl:8280/hudson/job/JBoss_VFS/org.jboss$jboss-vfs/9/testReport/org.jboss.test.virtual.test/LRUCacheTestCase/testCache/.

      By reverting http://fisheye.jboss.org/viewrep/JBossAS/trunk/server/src/etc/conf/default/initialize.xml?r1=80594&r2=80622 I can get the server to boot; this may not be a complete workaround though.

      https://jira.jboss.org/jira/browse/JBVFS-68

      S,
      ALR

        • 1. Re:
          Ales Justin Master

          OK, fixed.
          I'll do new CR release, making it easy on everybody.

          Is there any other dot feature out there that I should consider valid?

          I'll still leave triple '...' and '..somepath' as illegal:

           else if (ch == '.')
           {
           int bufferLength = buffer.length();
          
           if (specialToken == null && bufferLength == 0)
           specialToken = CURRENT_PATH;
           else if (specialToken == CURRENT_PATH && bufferLength == 0)
           specialToken = REVERSE_PATH;
           else if (specialToken == REVERSE_PATH && bufferLength == 0)
           throw new IllegalArgumentException("Illegal token (" + specialToken + ch + ") in path: " + path);
           else
           buffer.append(ch);
           }
           else
           {
           // token starts with '.' or '..', but also has some path after that
           if (specialToken != null)
           {
           // we don't allow tokens after '..'
           if (specialToken == REVERSE_PATH)
           throw new IllegalArgumentException("Illegal token (" + specialToken + ch + ") in path: " + path);
          
           // after '.' more path is legal == unix hidden directories
           buffer.append(specialToken);
           specialToken = null;
           }
           buffer.append(ch);
           }
          


          • 2. Re:
            David Lloyd Master

            Any number of "." in any position in a path element should be valid IMO. Is there a good reason to not allow this?

            • 3. Re:
              Ales Justin Master

               

              "david.lloyd@jboss.com" wrote:
              Is there a good reason to not allow this?

              Trying to help users?
              As I doubt someone intentionally puts '...' or '..somepath' (if this is not legal) into VirtualFile::findChild.

              At the beginning we didn't even allow '.' or '..',
              so when I was implementing that, I left some restrictions.
              If they don't make sense, I can easily remove them.


              • 4. Re:
                Scott Stark Master

                I don't see that we are helping as '.*x' is a valid file name. We just need to handle the distinct names '.' and '..' as relative paths and anything else is just another name, however strange it might be.

                • 5. Re:
                  David Lloyd Master

                  Agreed.

                  • 6. Re: Illegal tokens
                    Ales Justin Master

                     

                    "scott.stark@jboss.org" wrote:
                    I don't see that we are helping as '.*x' is a valid file name. We just need to handle the distinct names '.' and '..' as relative paths and anything else is just another name, however strange it might be.

                    OK, I'll disable it by default:
                    + /** Catch some suspicious tokens */
                    + private static boolean errorOnSuspiciousTokens;
                    +
                     /**
                     * Utility class
                     */
                    @@ -124,7 +127,13 @@
                     else if (specialToken == CURRENT_PATH && bufferLength == 0)
                     specialToken = REVERSE_PATH;
                     else if (specialToken == REVERSE_PATH && bufferLength == 0)
                    - throw new IllegalArgumentException("Illegal token (" + specialToken + ch + ") in path: " + path);
                    + {
                    + if (errorOnSuspiciousTokens)
                    + throw new IllegalArgumentException("Illegal token (" + specialToken + ch + ") in path: " + path);
                    +
                    + buffer.append(specialToken).append(ch);
                    + specialToken = null;
                    + }
                     else
                     buffer.append(ch);
                     }
                    @@ -134,7 +143,7 @@
                     if (specialToken != null)
                     {
                     // we don't allow tokens after '..'
                    - if (specialToken == REVERSE_PATH)
                    + if (errorOnSuspiciousTokens && specialToken == REVERSE_PATH)
                     throw new IllegalArgumentException("Illegal token (" + specialToken + ch + ") in path: " + path);
                    
                     // after '.' more path is legal == unix hidden directories
                    @@ -222,4 +231,14 @@
                     {
                     return REVERSE_PATH == token;
                     }
                    +
                    + /**
                    + * Set errorOnSuspiciousTokens flag.
                    + *
                    + * @param errorOnSuspiciousTokens the errorOnSuspiciousTokens flag
                    + */
                    + public static void setErrorOnSuspiciousTokens(boolean errorOnSuspiciousTokens)
                    + {
                    + PathTokenizer.errorOnSuspiciousTokens = errorOnSuspiciousTokens;
                    + }
                    

                    But advanced user can still turn it on.
                    e.g. initialize.xml in JBossAS