multipass 1.2.1 → 1.2.2
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.
- data/VERSION.yml +1 -1
- data/lib/multipass.rb +16 -4
- data/multipass.gemspec +2 -2
- data/test/multipass_test.rb +7 -0
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/multipass.rb
CHANGED
@@ -44,10 +44,8 @@ class MultiPass
|
|
44
44
|
# options:
|
45
45
|
# :url_safe => true
|
46
46
|
def initialize(site_key, api_key, options = {})
|
47
|
-
@site_key = site_key
|
48
|
-
@api_key = api_key
|
49
47
|
@url_safe = !options.key?(:url_safe) || options[:url_safe]
|
50
|
-
@crypto_key = EzCrypto::Key.with_password(
|
48
|
+
@crypto_key = EzCrypto::Key.with_password(site_key, api_key)
|
51
49
|
end
|
52
50
|
|
53
51
|
def url_safe?
|
@@ -81,7 +79,7 @@ class MultiPass
|
|
81
79
|
end
|
82
80
|
|
83
81
|
options.keys.each do |key|
|
84
|
-
options[key.to_sym] = options.delete(key)
|
82
|
+
options[key.to_sym] = unencode_javascript_unicode_escape(options.delete(key))
|
85
83
|
end
|
86
84
|
|
87
85
|
if options[:expires].nil? || Time.now.utc > Time.parse(options[:expires])
|
@@ -101,6 +99,20 @@ class MultiPass
|
|
101
99
|
require 'base64'
|
102
100
|
end
|
103
101
|
|
102
|
+
# converts unicode (\u003c) to the actual character
|
103
|
+
# http://rishida.net/tools/conversion/
|
104
|
+
def unencode_javascript_unicode_escape(str)
|
105
|
+
str.gsub!(/\\u([0-9a-fA-F]{4})/) do |s|
|
106
|
+
int = $1.to_i(16)
|
107
|
+
if int.zero? && s != "0000"
|
108
|
+
s
|
109
|
+
else
|
110
|
+
[int].pack("U")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
str
|
114
|
+
end
|
115
|
+
|
104
116
|
def self.encode_64(s, url_safe = true)
|
105
117
|
b = Base64.encode64(s)
|
106
118
|
b.gsub! /\n/, ''
|
data/multipass.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{multipass}
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["rick"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-05}
|
13
13
|
s.email = %q{technoweenie@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
data/test/multipass_test.rb
CHANGED
@@ -20,6 +20,13 @@ module MultiPassTests
|
|
20
20
|
assert_equal @input, MultiPass.decode('example', 'abc', encoded)
|
21
21
|
end
|
22
22
|
|
23
|
+
def test_decodes_unicode
|
24
|
+
@input[:name] = "Bj\\u00f8rn"
|
25
|
+
encoded = @mp.encode(@input)
|
26
|
+
decoded = @mp.decode(encoded)
|
27
|
+
assert_equal "Bjørn", decoded[:name]
|
28
|
+
end
|
29
|
+
|
23
30
|
def test_invalidates_bad_string
|
24
31
|
assert_raises MultiPass::DecryptError do
|
25
32
|
@mp.decode("abc")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multipass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rick
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-05 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|