files.com 1.0.331 → 1.0.333

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14222b37137fc5a7dbd47f3ae067b97f9dc26eadf43362675c919af12f9e3046
4
- data.tar.gz: fed625035ea60ba05ebeecb5da4b75abef6b0b6a7e01ccdb5b78e6e03b38e652
3
+ metadata.gz: f66268de3c346a62ee07907abf6c0ee4454c32033cd00592d3336b3a043f2c02
4
+ data.tar.gz: '086fc0447193c38583978c16675231da91bbb536c118f14178419d953e55273e'
5
5
  SHA512:
6
- metadata.gz: b2df3ef6c1d9307110d0004e2d538d92b683e1d51b27a69e1f77c1708410caec422e3526212b223a3aacc40c19a1b61d5d7f5033efb64e36b26119eb594ffbf4
7
- data.tar.gz: 3a3c3f852739c6d0a23c9426a9eb256665eac8cfa9331ec5e3bbbea5302415b853b1cc9334bb79a3c2ab047fb5b1e9f88933822e9bb8d0123b54a4bf428993e7
6
+ metadata.gz: fcb8126dd3284ab0650357d28123aa57ff642d3a7776870649cea3db2170f80d5c62b47ec591320e3eeac72872f165bb2106652e8c93fb6dce9debaa67e18054
7
+ data.tar.gz: 6c13961ae3b576c4364d6649b80f70b43ad4b82fe2a422573832fdd56a2f88cd7e95517f49f844f3534a7b04d4502a4b74d16d2960e6812a5dbda3084de1d6da
data/_VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.331
1
+ 1.0.333
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Files
4
+ module PathUtil
5
+ TRANSLIT_MAP = "ÀA,ÁA,ÂA,ÃA,ÄA,ÅA,ÆAE,ÇC,ÈE,ÉE,ÊE,ËE,ÌI,ÍI,ÎI,ÏI,ÐD,ÑN,ÒO,ÓO,ÔO,ÕO,ÖO,ØO,ÙU,ÚU,ÛU,ÜU,ÝY,ßss,àa,áa,âa,ãa,äa,åa,æae,çc,èe,ée,êe,ëe,ìi,íi,îi,ïi,ðd,ñn,òo,óo,ôo,õo,öo,øo,ùu,úu,ûu,üu,ýy,ÿy,ĀA,āa,ĂA,ăa,ĄA,ąa,ĆC,ćc,ĈC,ĉc,ĊC,ċc,ČC,čc,ĎD,ďd,ĐD,đd,ĒE,ēe,ĔE,ĕe,ĖE,ėe,ĘE,ęe,ĚE,ěe,ĜG,ĝg,ĞG,ğg,ĠG,ġg,ĢG,ģg,ĤH,ĥh,ĦH,ħh,ĨI,ĩi,ĪI,īi,ĬI,ĭi,ĮI,įi,İI,IJIJ,ijij,ĴJ,ĵj,ĶK,ķk,ĹL,ĺl,ĻL,ļl,ĽL,ľl,ŁL,łl,ŃN,ńn,ŅN,ņn,ŇN,ňn,ʼn'n,ŌO,ōo,ŎO,ŏo,ŐO,őo,ŒOE,œoe,ŔR,ŕr,ŖR,ŗr,ŘR,řr,ŚS,śs,ŜS,ŝs,ŞS,şs,ŠS,šs,ŢT,ţt,ŤT,ťt,ŨU,ũu,ŪU,ūu,ŬU,ŭu,ŮU,ůu,ŰU,űu,ŲU,ųu,ŴW,ŵw,ŶY,ŷy,ŸY,ŹZ,źz,ŻZ,żz,ŽZ,žz".split(",").to_h { |val| [ val[0], val[1..2] ] }.freeze
6
+
7
+ def self.normalize_for_comparison(*args)
8
+ unicode_normalize_and_transliterate(normalize(*args).to_s).downcase.rstrip
9
+ end
10
+
11
+ def self.same?(a, b)
12
+ normalize_for_comparison(a) == normalize_for_comparison(b)
13
+ end
14
+
15
+ def self.cleanpath(path)
16
+ new_path = Pathname.new(path).cleanpath.to_s
17
+
18
+ return "" if [ ".", ".." ].include? new_path
19
+ return new_path[1..] if new_path.index('/') == 0
20
+
21
+ new_path
22
+ end
23
+
24
+ private_class_method def self.normalize(*paths)
25
+ all_paths = paths.flatten.compact.map { |path| u8(path).gsub("\x00", "").gsub("\\", "/").split("/") }.flatten
26
+ all_paths.map { |path| cleanpath(path) }.reject(&:empty?).join("/")
27
+ end
28
+
29
+ private_class_method def self.u8(str)
30
+ new_string = begin
31
+ str.encode("UTF-8")
32
+ rescue Encoding::UndefinedConversionError
33
+ str.dup.force_encoding("UTF-8")
34
+ end
35
+
36
+ if new_string.valid_encoding?
37
+ new_string
38
+ else
39
+ new_string.force_encoding("ISO-8859-1").encode("UTF-8")
40
+ end
41
+ end
42
+
43
+ private_class_method def self.unicode_normalize_and_transliterate(string)
44
+ # convert multi-code-point characters into single-code-point characters
45
+ normalized_string = string.unicode_normalize(:nfkc)
46
+
47
+ normalized_string.gsub(/[^\x00-\x7f]/u) do |char|
48
+ TRANSLIT_MAP[char] || char
49
+ end
50
+ end
51
+ end
52
+ end
data/lib/files.com.rb CHANGED
@@ -30,6 +30,7 @@ require "files.com/system_profiler"
30
30
  require "files.com/util"
31
31
  require "files.com/list"
32
32
  require "files.com/uri"
33
+ require "files.com/path_util"
33
34
 
34
35
  require "files.com/models/account_line_item"
35
36
  require "files.com/models/action"
@@ -0,0 +1,49 @@
1
+ [
2
+ [ "filename.txt", "filename.txt" ],
3
+ [ "FiLeNaMe.TxT", "filename.txt" ],
4
+ [ "FILENAME.TXT", "filename.txt" ],
5
+ [ "FÎŁĘÑÂMÉ.TXT", "filename.txt" ],
6
+ [ "Fïłèńämê.Txt", "filename.txt" ],
7
+ [ "a/b/c.txt", "a/b/c.txt" ],
8
+ [ "A\\B\\C.TXT", "a/b/c.txt" ],
9
+ [ "A/B\\C.TXT", "a/b/c.txt" ],
10
+ [ "//a/b//c.txt", "a/b/c.txt" ],
11
+ [ "a/b/c.txt ", "a/b/c.txt" ],
12
+ [ "a/b/c.txt\t", "a/b/c.txt" ],
13
+ [ "a/b/c.txt\n", "a/b/c.txt" ],
14
+ [ "a/b/c.txt\r", "a/b/c.txt" ],
15
+ [ " space_at_beginning", " space_at_beginning"],
16
+ [ "space_at_end ", "space_at_end"],
17
+ [ "tab\tseperated", "tab\tseperated"],
18
+ [ "<title>hello</hello>", "<title>hello</hello>"],
19
+ [ "안녕하세요", "안녕하세요" ],
20
+ [ "こんにちは", "こんにちは" ],
21
+ [ "今日は", "今日は" ],
22
+ [ "longest_unicode_character_﷽", "longest_unicode_character_﷽"],
23
+ [ "invalid_null_byte_before\u0000after", "invalid_null_byte_beforeafter" ],
24
+ [ "a/b/c/../../hello", "a/b/c/hello" ],
25
+ [ "a/b/c/././hello", "a/b/c/hello" ],
26
+ [ "one_code_point_ą", "one_code_point_a" ],
27
+ [ "two_code_points_ą", "two_code_points_a" ],
28
+ [ "one_code_point_훯", "one_code_point_훯"],
29
+ [ "three_code_points_훯", "three_code_points_훯" ],
30
+ [ "ÞþŊŋŦŧ", "þþŋŋŧŧ" ],
31
+ [ "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ", "aaaaaaaeceeeeiiiidnoooooouuuuyssaaaaaaaeceeeeiiiidnoooooouuuuyy" ],
32
+ [ "ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİIJij", "aaaaaaccccccccddddeeeeeeeeeegggggggghhhhiiiiiiiiiijij" ],
33
+ [ "ĴĵĶķĹĺĻļĽľŁłŃńŅņŇňʼnŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤť", "jjkkllllllllnnnnnnʼnoooooooeoerrrrrrsssssssstttt" ],
34
+ [ "ŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽž", "uuuuuuuuuuuuwwyyyzzzzzz" ],
35
+ [ "😂❤️😍🤣😊🙏💕😭😘👍😅👏😁♥️🔥💔💖💙😢🤔😆🙄💪😉☺️👌🤗", "😂❤️😍🤣😊🙏💕😭😘👍😅👏😁♥️🔥💔💖💙😢🤔😆🙄💪😉☺️👌🤗" ],
36
+ [ "💜😔😎😇🌹🤦🎉💞✌️✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣️", "💜😔😎😇🌹🤦🎉💞✌️✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣️" ],
37
+ [ "emoji_‼️", "emoji_!!️" ],
38
+ [ "<title>hello<:hello>.txt", "<title>hello<:hello>.txt" ],
39
+ [ "twodotfile..txt", "twodotfile..txt" ],
40
+ [ "three/.../dots_path", "three/.../dots_path" ],
41
+ [ ".", "" ],
42
+ [ "..", ""],
43
+ [ "./..", "" ],
44
+ [ "../..", ""],
45
+ [ "./.", "" ],
46
+ [ "../.", ""],
47
+ [ "./../.", "" ],
48
+ [ ".././..", ""]
49
+ ]
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+ require 'json'
3
+
4
+ RSpec.describe Files::PathUtil do
5
+ json_str = File.read("shared/normalization_for_comparison_test_data.json")
6
+ test_cases = JSON.parse json_str
7
+
8
+ test_cases.each do |test_case_info|
9
+ src_chars, dst_chars = test_case_info
10
+ example "normalizes #{src_chars} to #{dst_chars}" do
11
+ expect(Files::PathUtil.same?(src_chars, dst_chars)).to eq(true)
12
+ end
13
+ end
14
+ 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.331
4
+ version: 1.0.333
5
5
  platform: ruby
6
6
  authors:
7
7
  - files.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-19 00:00:00.000000000 Z
11
+ date: 2023-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -277,15 +277,18 @@ files:
277
277
  - lib/files.com/models/user_cipher_use.rb
278
278
  - lib/files.com/models/user_request.rb
279
279
  - lib/files.com/models/webhook_test.rb
280
+ - lib/files.com/path_util.rb
280
281
  - lib/files.com/response.rb
281
282
  - lib/files.com/sizable_io.rb
282
283
  - lib/files.com/system_profiler.rb
283
284
  - lib/files.com/uri.rb
284
285
  - lib/files.com/util.rb
285
286
  - lib/files.com/version.rb
287
+ - shared/normalization_for_comparison_test_data.json
286
288
  - spec/list_spec.rb
287
289
  - spec/models/file_spec.rb
288
290
  - spec/models/folder_spec.rb
291
+ - spec/path_util_spec.rb
289
292
  - spec/spec_helper.rb
290
293
  - spec/uri_spec.rb
291
294
  - test.sh