JBehave
  1. JBehave
  2. JBEHAVE-712

Spaces in path breaks StoryFinder().findPaths()

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.4
    • Fix Version/s: 3.6
    • Component/s: Core
    • Labels:
      None
    • Environment:
      JBehave 3.6-beta-3, Fedora 15, 64-bit, Java HotSpot 1.6.0_30, 64-bit
    • Number of attachments :
      0

      Description

      Constructions like:
      List<String> storyPaths = new StoryFinder().findPaths(codeLocationFromClass(getClass()), "*/.story", "**/*examples.story");
      or
      List<String> storyPaths = new StoryFinder().findPaths(codeLocationFromPath("somePath"), "*/.story", "**/*examples.story");
      doesn't work when there are spaces in a path (which are replaced to %20).

      An issue similar to JBEHAVE-389.

        Activity

        Hide
        Nicholas Smith added a comment -

        seeing the same in 3.5.3

        Show
        Nicholas Smith added a comment - seeing the same in 3.5.3
        Hide
        Mauro Talevi added a comment -

        Current 3.x design converts all code locations to URLs, which don't allow spaces, automatically encoded to %20 chars. Relative paths can contain spaces but not the base code location.

        For the moment, the only workaround is not use spaces in the code locations. A new design solution will need to be found for 4.x.

        Show
        Mauro Talevi added a comment - Current 3.x design converts all code locations to URLs, which don't allow spaces, automatically encoded to %20 chars. Relative paths can contain spaces but not the base code location. For the moment, the only workaround is not use spaces in the code locations. A new design solution will need to be found for 4.x.
        Mauro Talevi made changes -
        Field Original Value New Value
        Fix Version/s 4.x [ 18279 ]
        Hide
        Alexander Lehmann added a comment -

        I have just fixed another problem with codeLocationFromClass (JBEHAVE-729), I'll take a look if the space problem can be fixed as well

        Show
        Alexander Lehmann added a comment - I have just fixed another problem with codeLocationFromClass ( JBEHAVE-729 ), I'll take a look if the space problem can be fixed as well
        Hide
        Alexander Lehmann added a comment -

        https://github.com/alexlehm/jbehave-core/commit/a45988cf23b804dda32bcdaf69403da99f84d2fd

        JBEHAVE-712: Spaces in path breaks StoryFinder().findPaths()

        added method getPathFromURL to replace the URL.getFile() calls which do not decode encoded chars.
        The same problem appears with other chars that have to be encoded e.g. [], accented chars.
        One function in LoadFromRelativeFile used URLDecoder before, which is incorrect for + chars in path
        (the class doesn't have a unit test, so I couldn't actually check for that problem, but its fixed
        with the new call)

        Show
        Alexander Lehmann added a comment - https://github.com/alexlehm/jbehave-core/commit/a45988cf23b804dda32bcdaf69403da99f84d2fd JBEHAVE-712 : Spaces in path breaks StoryFinder().findPaths() added method getPathFromURL to replace the URL.getFile() calls which do not decode encoded chars. The same problem appears with other chars that have to be encoded e.g. [], accented chars. One function in LoadFromRelativeFile used URLDecoder before, which is incorrect for + chars in path (the class doesn't have a unit test, so I couldn't actually check for that problem, but its fixed with the new call)
        Hide
        Alexander Lehmann added a comment -

        JBEHAVE-635 describes a similar issue that should be fixed as well.

        I think there was an issue with %5b %5d "[]" as well but I cannot find it now.

        Show
        Alexander Lehmann added a comment - JBEHAVE-635 describes a similar issue that should be fixed as well. I think there was an issue with %5b %5d "[]" as well but I cannot find it now.
        Hide
        Alexander Lehmann added a comment -

        added an unit test to show the issue with + chars in path (also fixed by the commit for this issue)

        https://github.com/alexlehm/jbehave-core/commit/b379d215a9404bae6d515e65909c28bac85f3a51

        Show
        Alexander Lehmann added a comment - added an unit test to show the issue with + chars in path (also fixed by the commit for this issue) https://github.com/alexlehm/jbehave-core/commit/b379d215a9404bae6d515e65909c28bac85f3a51
        Hide
        Marcin Zajaczkowski added a comment -

        Great, thanks Alexander. I will try to test it when will be merged into a snapshot or a beta version.

        Show
        Marcin Zajaczkowski added a comment - Great, thanks Alexander. I will try to test it when will be merged into a snapshot or a beta version.
        Hide
        Alexander Lehmann added a comment -

        one of the unit tests for shouldHandleSpacesAndSpecialChars to work on unix
        https://github.com/alexlehm/jbehave-core/commit/219810356553e0e9dd12eb45957ef85042b0faeb

        Show
        Alexander Lehmann added a comment - one of the unit tests for shouldHandleSpacesAndSpecialChars to work on unix https://github.com/alexlehm/jbehave-core/commit/219810356553e0e9dd12eb45957ef85042b0faeb
        Hide
        Mauro Talevi added a comment -

        Applied patches from Alex Lehmann.

        Show
        Mauro Talevi added a comment - Applied patches from Alex Lehmann.
        Mauro Talevi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 3.6 [ 17721 ]
        Fix Version/s 4.x [ 18279 ]
        Resolution Fixed [ 1 ]
        Hide
        Stephen Kurlow added a comment -

        This has regressed in at least v3.9.1

        Show
        Stephen Kurlow added a comment - This has regressed in at least v3.9.1
        Hide
        Mauro Talevi added a comment -

        Can you provide an example or a unit test reproducing the problem?

        Show
        Mauro Talevi added a comment - Can you provide an example or a unit test reproducing the problem?
        Hide
        Alexander Lehmann added a comment -

        I think the old unit test should check for that, I will take a look

        Show
        Alexander Lehmann added a comment - I think the old unit test should check for that, I will take a look
        Hide
        Stephen Kurlow added a comment - - edited

        I haven't written a failing unit test yet but I noticed if I change my code from:

        URL searchDir = codeLocationFromClass(this.getClass());
        List<String> paths = new StoryFinder().findPaths(searchDir.getFile(), asList(getPathFilter()), null);

        to:

        URL searchDir = codeLocationFromClass(this.getClass());
        List<String> paths = new StoryFinder().findPaths(searchDir, asList(getPathFilter()), null);

        then the issue goes away.

        At first I thought the issue had regressed but now I realise a different variant of findPaths() was being called being the one that has a String as first argument.

        Sorry to have bothered you all. Thanks for the mighty quick response!

        Show
        Stephen Kurlow added a comment - - edited I haven't written a failing unit test yet but I noticed if I change my code from: URL searchDir = codeLocationFromClass(this.getClass()); List<String> paths = new StoryFinder().findPaths(searchDir.getFile(), asList(getPathFilter()), null); to: URL searchDir = codeLocationFromClass(this.getClass()); List<String> paths = new StoryFinder().findPaths(searchDir, asList(getPathFilter()), null); then the issue goes away. At first I thought the issue had regressed but now I realise a different variant of findPaths() was being called being the one that has a String as first argument. Sorry to have bothered you all. Thanks for the mighty quick response!

          People

          • Assignee:
            Unassigned
            Reporter:
            Marcin Zajaczkowski
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: