files.com 1.0.110 → 1.0.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/_VERSION +1 -1
- data/lib/files.com.rb +1 -0
- data/lib/files.com/api_client.rb +3 -2
- data/lib/files.com/uri.rb +70 -0
- data/spec/uri_spec.rb +11 -0
- metadata +4 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 225dfeba48af26960bc78d58fcc6582130528647e1f4f8cbe46883f79a24cc78
         | 
| 4 | 
            +
              data.tar.gz: e432cdc6416e3ff8f24911833c33f244dc6d3c030db9a1ea1d517ab4e7038098
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ca79ab1f63905d8a1d91ebf3a4c620ec0d1f10024b6786162e6735266a1dc2c548bde72461f7ec2e653dd5bab918505b3b6bd99ed887c3152ae76d252fc55919
         | 
| 7 | 
            +
              data.tar.gz: 067e4d6f28a7ecfdd71b327e026a6414988384639af8546dcc8dd0a52da280be8ded9af59b6146d99f43c3d6bd6a9ae832c4eef7af344bfb3cddeeedc6971c89
         | 
    
        data/_VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            1.0. | 
| 1 | 
            +
            1.0.111
         | 
    
        data/lib/files.com.rb
    CHANGED
    
    
    
        data/lib/files.com/api_client.rb
    CHANGED
    
    | @@ -172,9 +172,10 @@ module Files | |
| 172 172 | 
             
                private def api_url(url = "", base_url = nil)
         | 
| 173 173 | 
             
                  uri        = Addressable::URI.new
         | 
| 174 174 | 
             
                  uri.host   = Addressable::URI.parse(base_url).host
         | 
| 175 | 
            -
                  uri.path   = "/api/rest/v1" + url
         | 
| 175 | 
            +
                  uri.path   = "/api/rest/v1" + Files::URI.normalized_path(url)
         | 
| 176 176 | 
             
                  uri.scheme = Addressable::URI.parse(base_url).scheme
         | 
| 177 | 
            -
             | 
| 177 | 
            +
             | 
| 178 | 
            +
                  uri.to_s
         | 
| 178 179 | 
             
                end
         | 
| 179 180 |  | 
| 180 181 | 
             
                private def check_api_key!(api_key)
         | 
| @@ -0,0 +1,70 @@ | |
| 1 | 
            +
            module Files
         | 
| 2 | 
            +
              module URI
         | 
| 3 | 
            +
                # This is a copy of Addressable::URI.normalize_component without Addressable::IDNA.unicode_normalize_kc.
         | 
| 4 | 
            +
                def self.normalize_component(component, character_class =
         | 
| 5 | 
            +
                    Addressable::URI::CharacterClasses::RESERVED + Addressable::URI::CharacterClasses::UNRESERVED,
         | 
| 6 | 
            +
                                             leave_encoded = '')
         | 
| 7 | 
            +
                  return nil if component.nil?
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  unless component.is_a? String
         | 
| 10 | 
            +
                    begin
         | 
| 11 | 
            +
                      component = component.to_str
         | 
| 12 | 
            +
                    rescue NoMethodError, TypeError
         | 
| 13 | 
            +
                      raise TypeError, "Can't convert #{component.class} into String."
         | 
| 14 | 
            +
                    end
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  unless [ String, Regexp ].include?(character_class.class)
         | 
| 18 | 
            +
                    raise TypeError,
         | 
| 19 | 
            +
                          "Expected String or Regexp, got #{character_class.inspect}"
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                  if character_class.is_a?(String)
         | 
| 22 | 
            +
                    leave_re = unless leave_encoded.empty?
         | 
| 23 | 
            +
                                 character_class = "#{character_class}%" unless character_class.include?('%')
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                                 "|%(?!#{leave_encoded.chars.map do |char|
         | 
| 26 | 
            +
                                   seq = SEQUENCE_ENCODING_TABLE[char]
         | 
| 27 | 
            +
                                   [ seq.upcase, seq.downcase ]
         | 
| 28 | 
            +
                                 end.flatten.join('|')})"
         | 
| 29 | 
            +
                               end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    character_class = /[^#{character_class}]#{leave_re}/
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                  # We can't perform regexps on invalid UTF sequences, but
         | 
| 34 | 
            +
                  # here we need to, so switch to ASCII.
         | 
| 35 | 
            +
                  component = component.dup
         | 
| 36 | 
            +
                  component.force_encoding(Encoding::ASCII_8BIT)
         | 
| 37 | 
            +
                  unencoded = Addressable::URI.unencode_component(component, String, leave_encoded)
         | 
| 38 | 
            +
                  begin
         | 
| 39 | 
            +
                    encoded = Addressable::URI.encode_component(
         | 
| 40 | 
            +
                      # Addressable::IDNA.unicode_normalize_kc(unencoded),
         | 
| 41 | 
            +
                      unencoded,
         | 
| 42 | 
            +
                      character_class,
         | 
| 43 | 
            +
                      leave_encoded
         | 
| 44 | 
            +
                    )
         | 
| 45 | 
            +
                  rescue ArgumentError
         | 
| 46 | 
            +
                    encoded = encode_component(unencoded)
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
                  encoded.force_encoding(Encoding::UTF_8)
         | 
| 49 | 
            +
                  encoded
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                def self.normalized_path(path)
         | 
| 53 | 
            +
                  if path =~ Addressable::URI::NORMPATH
         | 
| 54 | 
            +
                    # Relative paths with colons in the first segment are ambiguous.
         | 
| 55 | 
            +
                    path = path.sub(":", "%2F")
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
                  # String#split(delimeter, -1) uses the more strict splitting behavior
         | 
| 58 | 
            +
                  # found by default in Python.
         | 
| 59 | 
            +
                  result = path.strip.split(Addressable::URI::SLASH, -1).map do |segment|
         | 
| 60 | 
            +
                    normalize_component(
         | 
| 61 | 
            +
                      segment,
         | 
| 62 | 
            +
                      Addressable::URI::CharacterClasses::PCHAR
         | 
| 63 | 
            +
                    )
         | 
| 64 | 
            +
                  end.join(Addressable::URI::SLASH)
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                  # All normalized values should be UTF-8
         | 
| 67 | 
            +
                  result.force_encoding(Encoding::UTF_8)
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
            end
         | 
    
        data/spec/uri_spec.rb
    ADDED
    
    | @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            require "spec_helper"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            RSpec.describe Files::URI do
         | 
| 4 | 
            +
              describe "normalized_path" do
         | 
| 5 | 
            +
                it { expect(described_class.normalized_path("[[strange stuff]]#yes.text")).to eq("%5B%5Bstrange%20stuff%5D%5D%23yes.text") }
         | 
| 6 | 
            +
                it { expect(Addressable::URI.unencode_component(described_class.normalized_path("[[strange stuff]]#yes.text"))).to eq("[[strange stuff]]#yes.text") }
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                it { expect(described_class.normalized_path("folder/AdÇe")).to eq("folder/AdC%CC%A7e") }
         | 
| 9 | 
            +
                it { expect(Addressable::URI.unencode_component(described_class.normalized_path("AdÇe"))).to eq("AdÇe") }
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: files.com
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.111
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - files.com
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020- | 
| 11 | 
            +
            date: 2020-09-04 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: addressable
         | 
| @@ -211,12 +211,14 @@ files: | |
| 211 211 | 
             
            - lib/files.com/response.rb
         | 
| 212 212 | 
             
            - lib/files.com/sizable_io.rb
         | 
| 213 213 | 
             
            - lib/files.com/system_profiler.rb
         | 
| 214 | 
            +
            - lib/files.com/uri.rb
         | 
| 214 215 | 
             
            - lib/files.com/util.rb
         | 
| 215 216 | 
             
            - lib/files.com/version.rb
         | 
| 216 217 | 
             
            - spec/list_spec.rb
         | 
| 217 218 | 
             
            - spec/models/file_spec.rb
         | 
| 218 219 | 
             
            - spec/models/folder_spec.rb
         | 
| 219 220 | 
             
            - spec/spec_helper.rb
         | 
| 221 | 
            +
            - spec/uri_spec.rb
         | 
| 220 222 | 
             
            - test.sh
         | 
| 221 223 | 
             
            - test/test.rb
         | 
| 222 224 | 
             
            homepage: https://www.files.com
         |