Skip to content

Commit

Permalink
Obsolete URI.encode is replaced with URI.encode_www_form_component (f…
Browse files Browse the repository at this point in the history
…ixes #15, will be released in v1.6.1)
  • Loading branch information
detunized committed May 17, 2020
1 parent ecc7ddb commit ad13eb8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/lastpass/fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def self.login username, password, multifactor_password = nil, client_id = nil

def self.logout session, web_client = http
response = web_client.get "https://lastpass.com/logout.php?method=cli&noredirect=1",
cookies: {"PHPSESSID" => URI.encode(session.id)}
cookies: {"PHPSESSID" => URI.encode_www_form_component(session.id)}

raise NetworkError unless response.response.is_a? Net::HTTPOK
end

def self.fetch session, web_client = http
response = web_client.get "https://lastpass.com/getaccts.php?mobile=1&b64=1&hash=0.0&hasplugin=3.0.23&requestsrc=cli",
format: :plain,
cookies: {"PHPSESSID" => URI.encode(session.id)}
cookies: {"PHPSESSID" => URI.encode_www_form_component(session.id)}

raise NetworkError unless response.response.is_a? Net::HTTPOK

Expand Down
5 changes: 3 additions & 2 deletions spec/fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

let(:hash) { "7880a04588cfab954aa1a2da98fd9c0d2c6eba4c53e36a94510e6dbf30759256" }
let(:session_id) { "53ru,Hb713QnEVM5zWZ16jMvxS0" }
let(:escaped_session_id) { "53ru%2CHb713QnEVM5zWZ16jMvxS0" }
let(:session) { LastPass::Session.new session_id, key_iteration_count, "DEADBEEF" }

let(:blob_response) { "TFBBVgAAAAMxMjJQUkVNAAAACjE0MTQ5" }
Expand All @@ -36,7 +37,7 @@
it "makes a GET request" do
web_client = double "web_client"
expect(web_client).to receive(:get)
.with("https://lastpass.com/logout.php?method=cli&noredirect=1", cookies: {"PHPSESSID" => session_id})
.with("https://lastpass.com/logout.php?method=cli&noredirect=1", cookies: {"PHPSESSID" => escaped_session_id})
.and_return(http_ok "")
LastPass::Fetcher.logout session, web_client
end
Expand Down Expand Up @@ -199,7 +200,7 @@ def verify_post_request multifactor_password, device_id, post_data
expect(web_client = double("web_client")).to receive(:get)
.with("https://lastpass.com/getaccts.php?mobile=1&b64=1&hash=0.0&hasplugin=3.0.23&requestsrc=cli",
format: :plain,
cookies: {"PHPSESSID" => session_id})
cookies: {"PHPSESSID" => escaped_session_id})
.and_return(http_ok(blob_response))

LastPass::Fetcher.fetch session, web_client
Expand Down

0 comments on commit ad13eb8

Please sign in to comment.