Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When extending a schema in folder names with spaces #100

Closed
musshush opened this issue May 13, 2014 · 3 comments · Fixed by #188
Closed

When extending a schema in folder names with spaces #100

musshush opened this issue May 13, 2014 · 3 comments · Fixed by #188

Comments

@musshush
Copy link

If a schema is extended from a schema in folder with spaces in the name, it cannot load the reference schema and throws URI::InvalidURIError.

For example,

- project_name
   - folder name with spaces
      - base.json
      - extended.json

and extended.json

{
  "$schema" : "http://json-schema.org/draft-04/schema#",
  "type" : "object",
  "extends": { "$ref": "base.json" },
  "properties" : {
    "content" : {
      "type": "object"
      .......
      }
    }
  }
}
@pd
Copy link
Contributor

pd commented Oct 29, 2014

Confirmed; this can be reproduced trivially by just trying to run the test suite from within a directory with spaces in the name:

$ git clone git://github.com/hoxworth/json-schema.git 'json schema'
$ cd 'json schema' && rake
[snip]
Finished tests in 1.603910s, 420.8466 tests/s, 925.8624 assertions/s.
675 tests, 1485 assertions, 487 failures, 40 errors, 0 skips

@pd
Copy link
Contributor

pd commented Nov 25, 2014

I was hoping #174 had resolved this, but it's still reproducible using the command I referenced above. Current results:

$ rake
[snip]

580) Error:
JSONSchemaTest#test_file_ref:
Errno::ENOENT: No such file or directory @ rb_sysopen - /Users/pd/sauce/rb/json%20schema/test/schemas/good_schema_2.json

825 runs, 1241 assertions, 0 failures, 580 errors, 0 skips

@RST-J
Copy link
Contributor

RST-J commented Nov 25, 2014

This is because we use Addressable::URI.convert_path for paths.
In custom_open we need to use Addressable::URI.unescape for files and then this should be fine.
Compare

Addressable::URI.convert_path('/some/path/foo bar').path
# => "/some/path/foo%20bar"
Addressable::URI.unescape(Addressable::URI.convert_path('/some/path/foo bar').path)
# => "/some/path/foo bar" 

I'll prepare a PR later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants