{"action":"created","comment":{"url":"https://api.github.com/repos/monero-project/kovri/pulls/comments/173362925","pull_request_review_id":102541509,"id":173362925,"diff_hunk":"@@ -390,41 +422,94 @@ bool HTTPMessage::ExtractIncomingRequest() {\n   return true;\n }\n \n-void HTTPMessage::HandleJumpService() {\n-  // TODO(GUZZI) should have boolean return value; error\n-  // response?; research this\n+bool HTTPMessage::HandleJumpService()\n+{\n   // TODO(anonimal): add support for remaining services /\n   // rewrite this function\n-  std::size_t pos1 = m_Path.rfind(m_JumpService.at(0));\n-  std::size_t pos2 = m_Path.rfind(m_JumpService.at(1));\n-  std::size_t pos;\n-  if (pos1 == std::string::npos) {\n-    if (pos2 == std::string::npos)\n-      return;  // Not a jump service\n-    else\n-      pos = pos2;\n-  } else {\n-    if (pos2 == std::string::npos)\n-      pos = pos1;\n-    else if (pos1 > pos2)\n-      pos = pos1;\n-    else\n-      pos = pos2;\n-  }\n-  auto base64 = m_Path.substr(pos + m_JumpService.at(0).size());\n-  // We must decode\n-  base64 = boost::network::uri::decoded(base64);\n-  // Insert into address book\n-  LOG(debug)\n-    << \"HTTPProxyHandler: jump service for \" << m_Address\n-    << \" found at \" << base64 << \", inserting to address book\";\n-  // TODO(unassigned): this is very dangerous and broken.\n-  // We should ask the user for confirmation before proceeding.\n-  // Previous reference: http://pastethis.i2p/raw/pn5fL4YNJL7OSWj3Sc6N/\n-  // We *could* redirect the user again to avoid dirtiness in the browser\n-  kovri::client::context.GetAddressBook().InsertAddressIntoStorage(\n-      m_Address, base64);\n-  m_Path.erase(pos);\n+\n+  // Perform sanity check again to:\n+  // - ensure valid jump service request\n+  auto const pos = IsJumpServiceRequest();\n+  if (!pos)\n+    {\n+      LOG(error) << \"HTTPProxyHandler: not a valid jump service request\";\n+      // Jump service parameter not found in URL, so just return\n+      return false;\n+    }\n+\n+  if (!ExtractBase64Destination(pos))\n+    {\n+      LOG(error) << \"HTTPProxyHandler: unable to process base64 destination for \"\n+                 << m_Address;\n+      m_URL.erase(pos);\n+      return false;\n+    }\n+\n+  LOG(debug) << \"HTTPProxyHandler: jump service for \" << m_Address\n+             << \" found at \" << m_Base64Destination;\n+  m_URL.erase(pos);\n+  return true;\n+}\n+\n+std::size_t HTTPMessage::IsJumpServiceRequest() const\n+{\n+  std::size_t pos = 0;\n+  auto const pos1 = m_URL.rfind(m_JumpService.at(0));\n+  auto const pos2 = m_URL.rfind(m_JumpService.at(1));\n+  if (pos1 == std::string::npos)\n+    {\n+      if (pos2 == std::string::npos)\n+        return 0;  // Not a jump service\n+      else\n+        pos = pos2;\n+    }\n+  else\n+    {\n+      if (pos2 == std::string::npos)\n+        pos = pos1;\n+      else if (pos1 > pos2)\n+        pos = pos1;\n+      else\n+        pos = pos2;\n+    }\n+\n+  // final sanity check\n+  if (pos && pos != std::string::npos)\n+    return pos;\n+\n+  return 0;\n+}\n+\n+bool HTTPMessage::ExtractBase64Destination(std::size_t const pos)\n+{\n+  auto const base64_size = pos + m_JumpService.at(0).size();","path":"src/client/proxy/http.cc","position":138,"original_position":138,"commit_id":"256ce7b5d5e624fd53a7789f7cfa5200ea6cd12c","original_commit_id":"256ce7b5d5e624fd53a7789f7cfa5200ea6cd12c","user":{"login":"anonimal","id":12156341,"avatar_url":"https://avatars3.githubusercontent.com/u/12156341?v=4","gravatar_id":"","url":"https://api.github.com/users/anonimal","html_url":"https://github.com/anonimal","followers_url":"https://api.github.com/users/anonimal/followers","following_url":"https://api.github.com/users/anonimal/following{/other_user}","gists_url":"https://api.github.com/users/anonimal/gists{/gist_id}","starred_url":"https://api.github.com/users/anonimal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anonimal/subscriptions","organizations_url":"https://api.github.com/users/anonimal/orgs","repos_url":"https://api.github.com/users/anonimal/repos","events_url":"https://api.github.com/users/anonimal/events{/privacy}","received_events_url":"https://api.github.com/users/anonimal/received_events","type":"User","site_admin":false},"body":"https://github.com/monero-project/kovri/pull/813#discussion_r173045939","created_at":"2018-03-09T04:24:52Z","updated_at":"2018-03-09T04:26:27Z","html_url":"https://github.com/monero-project/kovri/pull/813#discussion_r173362925","pull_request_url":"https://api.github.com/repos/monero-project/kovri/pulls/813","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/monero-project/kovri/pulls/comments/173362925"},"html":{"href":"https://github.com/monero-project/kovri/pull/813#discussion_r173362925"},"pull_request":{"href":"https://api.github.com/repos/monero-project/kovri/pulls/813"}}},"pull_request":{"url":"https://api.github.com/repos/monero-project/kovri/pulls/813","id":170339873,"html_url":"https://github.com/monero-project/kovri/pull/813","diff_url":"https://github.com/monero-project/kovri/pull/813.diff","patch_url":"https://github.com/monero-project/kovri/pull/813.patch","issue_url":"https://api.github.com/repos/monero-project/kovri/issues/813","number":813,"state":"open","locked":false,"title":"HTTPMessage: refactor jump service parser + add test-cases","user":{"login":"coneiric","id":33737923,"avatar_url":"https://avatars0.githubusercontent.com/u/33737923?v=4","gravatar_id":"","url":"https://api.github.com/users/coneiric","html_url":"https://github.com/coneiric","followers_url":"https://api.github.com/users/coneiric/followers","following_url":"https://api.github.com/users/coneiric/following{/other_user}","gists_url":"https://api.github.com/users/coneiric/gists{/gist_id}","starred_url":"https://api.github.com/users/coneiric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coneiric/subscriptions","organizations_url":"https://api.github.com/users/coneiric/orgs","repos_url":"https://api.github.com/users/coneiric/repos","events_url":"https://api.github.com/users/coneiric/events{/privacy}","received_events_url":"https://api.github.com/users/coneiric/received_events","type":"User","site_admin":false},"body":"---\r\n**By submitting this pull-request, I confirm the following:**\r\n\r\n- I have read and understood the contributor guide in [kovri-docs](https://github.com/monero-project/kovri-docs).\r\n- I have checked that another pull-request for this purpose does not exist.\r\n- I have considered and confirmed that this submission will be valuable to others.\r\n- I accept that this submission may not be used and that this pull-request may be closed by the will of the maintainer.\r\n- I give this submission freely under the BSD 3-clause license.\r\n---\r\n\r\nPart of #812, HTTPMessage::HandleJumpService now searches the HTTP URI for the `i2paddresshelper` parameter.\r\n\r\nUnit test to ensure correct handling of valid jump service parameter.\r\n\r\nStill requires unit tests for invalid parameters, and other failure cases.","created_at":"2018-02-20T23:38:40Z","updated_at":"2018-03-09T04:26:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7bb528b86619fcd5c575d1c41c7a438bf8f671c0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/monero-project/kovri/pulls/813/commits","review_comments_url":"https://api.github.com/repos/monero-project/kovri/pulls/813/comments","review_comment_url":"https://api.github.com/repos/monero-project/kovri/pulls/comments{/number}","comments_url":"https://api.github.com/repos/monero-project/kovri/issues/813/comments","statuses_url":"https://api.github.com/repos/monero-project/kovri/statuses/256ce7b5d5e624fd53a7789f7cfa5200ea6cd12c","head":{"label":"coneiric:http-proxy-jump","ref":"http-proxy-jump","sha":"256ce7b5d5e624fd53a7789f7cfa5200ea6cd12c","user":{"login":"coneiric","id":33737923,"avatar_url":"https://avatars0.githubusercontent.com/u/33737923?v=4","gravatar_id":"","url":"https://api.github.com/users/coneiric","html_url":"https://github.com/coneiric","followers_url":"https://api.github.com/users/coneiric/followers","following_url":"https://api.github.com/users/coneiric/following{/other_user}","gists_url":"https://api.github.com/users/coneiric/gists{/gist_id}","starred_url":"https://api.github.com/users/coneiric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coneiric/subscriptions","organizations_url":"https://api.github.com/users/coneiric/orgs","repos_url":"https://api.github.com/users/coneiric/repos","events_url":"https://api.github.com/users/coneiric/events{/privacy}","received_events_url":"https://api.github.com/users/coneiric/received_events","type":"User","site_admin":false},"repo":{"id":111350088,"name":"kovri","full_name":"coneiric/kovri","owner":{"login":"coneiric","id":33737923,"avatar_url":"https://avatars0.githubusercontent.com/u/33737923?v=4","gravatar_id":"","url":"https://api.github.com/users/coneiric","html_url":"https://github.com/coneiric","followers_url":"https://api.github.com/users/coneiric/followers","following_url":"https://api.github.com/users/coneiric/following{/other_user}","gists_url":"https://api.github.com/users/coneiric/gists{/gist_id}","starred_url":"https://api.github.com/users/coneiric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coneiric/subscriptions","organizations_url":"https://api.github.com/users/coneiric/orgs","repos_url":"https://api.github.com/users/coneiric/repos","events_url":"https://api.github.com/users/coneiric/events{/privacy}","received_events_url":"https://api.github.com/users/coneiric/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/coneiric/kovri","description":"The Kovri I2P Router Project","fork":true,"url":"https://api.github.com/repos/coneiric/kovri","forks_url":"https://api.github.com/repos/coneiric/kovri/forks","keys_url":"https://api.github.com/repos/coneiric/kovri/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coneiric/kovri/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coneiric/kovri/teams","hooks_url":"https://api.github.com/repos/coneiric/kovri/hooks","issue_events_url":"https://api.github.com/repos/coneiric/kovri/issues/events{/number}","events_url":"https://api.github.com/repos/coneiric/kovri/events","assignees_url":"https://api.github.com/repos/coneiric/kovri/assignees{/user}","branches_url":"https://api.github.com/repos/coneiric/kovri/branches{/branch}","tags_url":"https://api.github.com/repos/coneiric/kovri/tags","blobs_url":"https://api.github.com/repos/coneiric/kovri/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coneiric/kovri/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coneiric/kovri/git/refs{/sha}","trees_url":"https://api.github.com/repos/coneiric/kovri/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coneiric/kovri/statuses/{sha}","languages_url":"https://api.github.com/repos/coneiric/kovri/languages","stargazers_url":"https://api.github.com/repos/coneiric/kovri/stargazers","contributors_url":"https://api.github.com/repos/coneiric/kovri/contributors","subscribers_url":"https://api.github.com/repos/coneiric/kovri/subscribers","subscription_url":"https://api.github.com/repos/coneiric/kovri/subscription","commits_url":"https://api.github.com/repos/coneiric/kovri/commits{/sha}","git_commits_url":"https://api.github.com/repos/coneiric/kovri/git/commits{/sha}","comments_url":"https://api.github.com/repos/coneiric/kovri/comments{/number}","issue_comment_url":"https://api.github.com/repos/coneiric/kovri/issues/comments{/number}","contents_url":"https://api.github.com/repos/coneiric/kovri/contents/{+path}","compare_url":"https://api.github.com/repos/coneiric/kovri/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coneiric/kovri/merges","archive_url":"https://api.github.com/repos/coneiric/kovri/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coneiric/kovri/downloads","issues_url":"https://api.github.com/repos/coneiric/kovri/issues{/number}","pulls_url":"https://api.github.com/repos/coneiric/kovri/pulls{/number}","milestones_url":"https://api.github.com/repos/coneiric/kovri/milestones{/number}","notifications_url":"https://api.github.com/repos/coneiric/kovri/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coneiric/kovri/labels{/name}","releases_url":"https://api.github.com/repos/coneiric/kovri/releases{/id}","deployments_url":"https://api.github.com/repos/coneiric/kovri/deployments","created_at":"2017-11-20T02:02:39Z","updated_at":"2017-11-20T02:02:42Z","pushed_at":"2018-03-08T17:59:58Z","git_url":"git://github.com/coneiric/kovri.git","ssh_url":"git@github.com:coneiric/kovri.git","clone_url":"https://github.com/coneiric/kovri.git","svn_url":"https://github.com/coneiric/kovri","homepage":"","size":8919,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"monero-project:master","ref":"master","sha":"aa05985c9562d4e11af8426b49db0de73961c794","user":{"login":"monero-project","id":7450663,"avatar_url":"https://avatars2.githubusercontent.com/u/7450663?v=4","gravatar_id":"","url":"https://api.github.com/users/monero-project","html_url":"https://github.com/monero-project","followers_url":"https://api.github.com/users/monero-project/followers","following_url":"https://api.github.com/users/monero-project/following{/other_user}","gists_url":"https://api.github.com/users/monero-project/gists{/gist_id}","starred_url":"https://api.github.com/users/monero-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monero-project/subscriptions","organizations_url":"https://api.github.com/users/monero-project/orgs","repos_url":"https://api.github.com/users/monero-project/repos","events_url":"https://api.github.com/users/monero-project/events{/privacy}","received_events_url":"https://api.github.com/users/monero-project/received_events","type":"User","site_admin":false},"repo":{"id":46236248,"name":"kovri","full_name":"monero-project/kovri","owner":{"login":"monero-project","id":7450663,"avatar_url":"https://avatars2.githubusercontent.com/u/7450663?v=4","gravatar_id":"","url":"https://api.github.com/users/monero-project","html_url":"https://github.com/monero-project","followers_url":"https://api.github.com/users/monero-project/followers","following_url":"https://api.github.com/users/monero-project/following{/other_user}","gists_url":"https://api.github.com/users/monero-project/gists{/gist_id}","starred_url":"https://api.github.com/users/monero-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monero-project/subscriptions","organizations_url":"https://api.github.com/users/monero-project/orgs","repos_url":"https://api.github.com/users/monero-project/repos","events_url":"https://api.github.com/users/monero-project/events{/privacy}","received_events_url":"https://api.github.com/users/monero-project/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/monero-project/kovri","description":"The Kovri I2P Router Project","fork":false,"url":"https://api.github.com/repos/monero-project/kovri","forks_url":"https://api.github.com/repos/monero-project/kovri/forks","keys_url":"https://api.github.com/repos/monero-project/kovri/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monero-project/kovri/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monero-project/kovri/teams","hooks_url":"https://api.github.com/repos/monero-project/kovri/hooks","issue_events_url":"https://api.github.com/repos/monero-project/kovri/issues/events{/number}","events_url":"https://api.github.com/repos/monero-project/kovri/events","assignees_url":"https://api.github.com/repos/monero-project/kovri/assignees{/user}","branches_url":"https://api.github.com/repos/monero-project/kovri/branches{/branch}","tags_url":"https://api.github.com/repos/monero-project/kovri/tags","blobs_url":"https://api.github.com/repos/monero-project/kovri/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monero-project/kovri/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monero-project/kovri/git/refs{/sha}","trees_url":"https://api.github.com/repos/monero-project/kovri/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monero-project/kovri/statuses/{sha}","languages_url":"https://api.github.com/repos/monero-project/kovri/languages","stargazers_url":"https://api.github.com/repos/monero-project/kovri/stargazers","contributors_url":"https://api.github.com/repos/monero-project/kovri/contributors","subscribers_url":"https://api.github.com/repos/monero-project/kovri/subscribers","subscription_url":"https://api.github.com/repos/monero-project/kovri/subscription","commits_url":"https://api.github.com/repos/monero-project/kovri/commits{/sha}","git_commits_url":"https://api.github.com/repos/monero-project/kovri/git/commits{/sha}","comments_url":"https://api.github.com/repos/monero-project/kovri/comments{/number}","issue_comment_url":"https://api.github.com/repos/monero-project/kovri/issues/comments{/number}","contents_url":"https://api.github.com/repos/monero-project/kovri/contents/{+path}","compare_url":"https://api.github.com/repos/monero-project/kovri/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monero-project/kovri/merges","archive_url":"https://api.github.com/repos/monero-project/kovri/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monero-project/kovri/downloads","issues_url":"https://api.github.com/repos/monero-project/kovri/issues{/number}","pulls_url":"https://api.github.com/repos/monero-project/kovri/pulls{/number}","milestones_url":"https://api.github.com/repos/monero-project/kovri/milestones{/number}","notifications_url":"https://api.github.com/repos/monero-project/kovri/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monero-project/kovri/labels{/name}","releases_url":"https://api.github.com/repos/monero-project/kovri/releases{/id}","deployments_url":"https://api.github.com/repos/monero-project/kovri/deployments","created_at":"2015-11-15T21:18:13Z","updated_at":"2018-03-05T02:26:33Z","pushed_at":"2018-03-09T01:15:47Z","git_url":"git://github.com/monero-project/kovri.git","ssh_url":"git@github.com:monero-project/kovri.git","clone_url":"https://github.com/monero-project/kovri.git","svn_url":"https://github.com/monero-project/kovri","homepage":"","size":8897,"stargazers_count":448,"watchers_count":448,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":77,"mirror_url":null,"archived":false,"open_issues_count":85,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":77,"open_issues":85,"watchers":448,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/monero-project/kovri/pulls/813"},"html":{"href":"https://github.com/monero-project/kovri/pull/813"},"issue":{"href":"https://api.github.com/repos/monero-project/kovri/issues/813"},"comments":{"href":"https://api.github.com/repos/monero-project/kovri/issues/813/comments"},"review_comments":{"href":"https://api.github.com/repos/monero-project/kovri/pulls/813/comments"},"review_comment":{"href":"https://api.github.com/repos/monero-project/kovri/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/monero-project/kovri/pulls/813/commits"},"statuses":{"href":"https://api.github.com/repos/monero-project/kovri/statuses/256ce7b5d5e624fd53a7789f7cfa5200ea6cd12c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"anonimal"}}