slosilo 2.0.0 → 2.0.1

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
  SHA1:
3
- metadata.gz: 761d6e24aaa95427bbc3d7449bc980b29b602bca
4
- data.tar.gz: 79950d2ab62c71a6f9ebdb1f68afdfd13c53894e
3
+ metadata.gz: b2f977e53f906393dcac0918f5fb5b2b2b41563b
4
+ data.tar.gz: 967b35f4ed8f91c24dfab09245ff0cb798b585ed
5
5
  SHA512:
6
- metadata.gz: de1ab282bd0067317a21e2d40dbb0668c737e487bc2e29e25120f460191d2c8a550b25ec98719a4d99d72176a73f0b47007703733ad5a0e77077a13c1fc54d6d
7
- data.tar.gz: e7444706c7f1af27f3a7eebf350252b37a033ca4b225a5d8ea6d24afbf49f40d42e6613187f8f0fe2322c9bf73dc1b54d5e36796ba7ef10aa8c95ff54f5aa8b3
6
+ metadata.gz: fd31b09380e3f9411aca6a7ee9244d727e0962954da29c18adffa68b81b58265607205b5a519de8d211da07f412600788c1b5579fc0a604e06328e5bb86e62a8
7
+ data.tar.gz: 3454255c91a0a62c59bedf5b425e5b5a9fdb1ba29283d85ae0e5be7ca9b5cd2b1fa44b4fa280d65d37441d802e634309a928373848ad4cf199c9e5ac58d074cd
@@ -0,0 +1,4 @@
1
+ # v2.0.1
2
+
3
+ * Fixes a bug that occurs when signing tokens containing Unicode data
4
+
@@ -114,7 +114,7 @@ module Slosilo
114
114
  # Note that this is currently somewhat shallow stringification --
115
115
  # to implement originating tokens we may need to make it deeper.
116
116
  def stringify value
117
- case value
117
+ string = case value
118
118
  when Hash
119
119
  value.to_a.sort.to_json
120
120
  when String
@@ -122,6 +122,17 @@ module Slosilo
122
122
  else
123
123
  value.to_json
124
124
  end
125
+
126
+ # Make sure that the string is ascii_8bit (i.e. raw bytes), and represents
127
+ # the utf-8 encoding of the string. This accomplishes two things: it normalizes
128
+ # the representation of the string at the byte level (so we don't have an error if
129
+ # one username is submitted as ISO-whatever, and the next as UTF-16), and it prevents
130
+ # an incompatible encoding error when we concatenate it with the salt.
131
+ if string.encoding != Encoding::ASCII_8BIT
132
+ string.encode(Encoding::UTF_8).force_encoding(Encoding::ASCII_8BIT)
133
+ else
134
+ string
135
+ end
125
136
  end
126
137
 
127
138
  def shake_salt
@@ -1,3 +1,3 @@
1
1
  module Slosilo
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
@@ -145,6 +145,19 @@ describe Slosilo::Key do
145
145
  expect(key.sign("this sentence is not this sentence")).to eq(expected_signature)
146
146
  end
147
147
  end
148
+
149
+ context "when given a Hash containing non-ascii characters" do
150
+ let(:unicode){ "adèle.dupuis" }
151
+ let(:encoded){
152
+ unicode.dup.tap{|s| s.force_encoding Encoding::ASCII_8BIT}
153
+ }
154
+ let(:hash){ {"data" => unicode} }
155
+
156
+ it "converts the value to raw bytes before signing it" do
157
+ expect(key).to receive(:sign_string).with("[[\"data\",\"#{encoded}\"]]").and_call_original
158
+ key.sign hash
159
+ end
160
+ end
148
161
  end
149
162
 
150
163
  describe "#signed_token" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slosilo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafał Rzepecki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-14 00:00:00.000000000 Z
11
+ date: 2016-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -118,6 +118,7 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - .gitignore
120
120
  - .kateproject
121
+ - CHANGELOG.md
121
122
  - Gemfile
122
123
  - LICENSE
123
124
  - README.md
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  version: '0'
168
169
  requirements: []
169
170
  rubyforge_project:
170
- rubygems_version: 2.0.14
171
+ rubygems_version: 2.0.14.1
171
172
  signing_key:
172
173
  specification_version: 4
173
174
  summary: Store SSL keys in a database