Ticket #10829: Option to copy URL with password.patch
File Option to copy URL with password.patch, 18.9 KB (added by , 9 years ago) |
---|
-
src/engine/ControlSocket.cpp
1044 1044 1045 1045 const int proxy_type = engine_.GetOptions().GetOptionVal(OPTION_PROXY_TYPE); 1046 1046 if (proxy_type > CProxySocket::unknown && proxy_type < CProxySocket::proxytype_count && !m_pCurrentServer->GetBypassProxy()) { 1047 LogMessage(MessageType::Status, _("Connecting to %s through %s proxy"), m_pCurrentServer->Format Host(), CProxySocket::Name(static_cast<CProxySocket::ProxyType>(proxy_type)));1047 LogMessage(MessageType::Status, _("Connecting to %s through %s proxy"), m_pCurrentServer->FormatServer(SERVER_HOST_PORT), CProxySocket::Name(static_cast<CProxySocket::ProxyType>(proxy_type))); 1048 1048 1049 1049 host = engine_.GetOptions().GetOption(OPTION_PROXY_HOST); 1050 1050 port = engine_.GetOptions().GetOptionVal(OPTION_PROXY_PORT); -
src/engine/ftpcontrolsocket.cpp
526 526 pData->loginSequence.push_back(cmd); 527 527 } 528 528 // User@host 529 t_loginCommand cmd = {false, false, loginCommandType::user, wxString::Format(_T("USER %s@%s"), server.GetUser(), server.Format Host())};529 t_loginCommand cmd = {false, false, loginCommandType::user, wxString::Format(_T("USER %s@%s"), server.GetUser(), server.FormatServer(SERVER_HOST_PORT))}; 530 530 pData->loginSequence.push_back(cmd); 531 531 532 532 // Password … … 558 558 // Site or Open 559 559 t_loginCommand cmd = {false, false, loginCommandType::user, _T("")}; 560 560 if (pData->ftp_proxy_type == 2) 561 cmd.command = _T("SITE ") + server.Format Host();561 cmd.command = _T("SITE ") + server.FormatServer(SERVER_HOST_PORT); 562 562 else 563 cmd.command = _T("OPEN ") + server.Format Host();563 cmd.command = _T("OPEN ") + server.FormatServer(SERVER_HOST_PORT); 564 564 pData->loginSequence.push_back(cmd); 565 565 566 566 // User … … 584 584 else if (pData->ftp_proxy_type == 4) { 585 585 wxString proxyUser = engine_.GetOptions().GetOption(OPTION_FTP_PROXY_USER); 586 586 wxString proxyPass = engine_.GetOptions().GetOption(OPTION_FTP_PROXY_PASS); 587 wxString host = server.Format Host();587 wxString host = server.FormatServer(SERVER_HOST_PORT); 588 588 wxString user = server.GetUser(); 589 589 wxString account = server.GetAccount(); 590 590 proxyUser.Replace(_T("%"), _T("%%")); … … 4244 4244 return FZ_REPLY_ERROR; 4245 4245 } 4246 4246 4247 LogMessage(MessageType::Status, _("Connecting to %s through %s proxy"), server.FormatHost(), _T("FTP")); // @translator: Connecting to ftp.example.com through SOCKS5 proxy4247 LogMessage(MessageType::Status, _("Connecting to %s through %s proxy"), FormatServer(SERVER_HOST_PORT), _T("FTP")); // @translator: Connecting to ftp.example.com through SOCKS5 proxy 4248 4248 } 4249 4249 else { 4250 4250 pData->ftp_proxy_type = 0; -
src/engine/httpcontrolsocket.cpp
343 343 m_pCurOpData = pData; 344 344 m_pHttpOpData = pData; 345 345 346 m_current_uri = wxURI(m_pCurrentServer->FormatServer( ) + pData->remotePath.FormatFilename(pData->remoteFile));346 m_current_uri = wxURI(m_pCurrentServer->FormatServer(SERVER_USER_HOST_PORT) + pData->remotePath.FormatFilename(pData->remoteFile)); 347 347 348 348 if (!localFile.empty()) { 349 349 pData->localFileSize = fz::local_filesys::get_size(fz::to_native(pData->localFile)); -
src/engine/server.cpp
637 637 return m_maximumMultipleConnections; 638 638 } 639 639 640 wxString CServer::Format Host(bool always_omit_port /*=false*/) const640 wxString CServer::FormatServer(FormatServerType formatType) const 641 641 { 642 wxString host= m_host;642 wxString server = m_host; 643 643 644 if ( host.Find(':') != -1)645 host = _T("[") + host+ _T("]");644 if (server.Find(':') != -1) 645 server = _T("[") + server + _T("]"); 646 646 647 if (!always_omit_port) 647 if (formatType == SERVER_HOST_ONLY) 648 return server; 649 650 if (m_port != GetDefaultPort(m_protocol) || expanded_form) 651 server += wxString::Format(_T(":%d"), m_port); 652 653 if (formatType == SERVER_HOST_PORT) 654 return server; 655 656 if (m_logonType != ANONYMOUS) 648 657 { 649 if (m_port != GetDefaultPort(m_protocol)) 650 host += wxString::Format(_T(":%d"), m_port); 658 if (formatType == SERVER_URL_PASSWORD) 659 server = GetUser() + _T(":") + GetPass() + _T("@") + server 660 else 661 server = GetUser() + _T("@") + server; 651 662 } 652 653 return host; 654 } 655 656 wxString CServer::FormatServer(const bool always_include_prefix /*=false*/) const 657 { 658 wxString server = FormatHost(); 659 660 if (m_logonType != ANONYMOUS) 661 server = GetUser() + _T("@") + server; 662 663 664 if (formatType == SERVER_USER_HOST_PORT) 665 { 666 if (info.alwaysShowPrefix || m_port != info.defaultPort) 667 formatType == SERVER_URL 668 else 669 return server; 670 } 671 663 672 const t_protocolInfo& info = GetProtocolInfo(m_protocol); 664 673 if (!info.prefix.empty()) 665 674 { 666 if (always_include_prefix || info.alwaysShowPrefix) 667 server = info.prefix + _T("://") + server; 668 else if (m_port != info.defaultPort) 669 server = info.prefix + _T("://") + server; 675 server = info.prefix + _T("://") + server; 670 676 } 671 677 672 678 return server; -
src/engine/sftpcontrolsocket.cpp
355 355 356 356 int CSftpControlSocket::Connect(const CServer &server) 357 357 { 358 LogMessage(MessageType::Status, _("Connecting to %s..."), server.Format Host());358 LogMessage(MessageType::Status, _("Connecting to %s..."), server.FormatServer(SERVER_HOST_PORT)); 359 359 SetWait(true); 360 360 361 361 m_sftpEncryptionDetails = CSftpEncryptionNotification(); -
src/include/server.h
60 60 ENCODING_CUSTOM 61 61 }; 62 62 63 enum FormatServerType 64 { 65 SERVER_HOST_ONLY, 66 SERVER_HOST_PORT, 67 SERVER_USER_HOST_PORT, 68 SERVER_URL, 69 SERVER_URL_PASSWORD 70 }; 71 63 72 class CServerPath; 64 73 class CServer final 65 74 { … … 111 120 void SetPasvMode(PasvMode pasvMode); 112 121 void MaximumMultipleConnections(int maximum); 113 122 114 wxString FormatHost(bool always_omit_port = false) const; 115 wxString FormatServer(const bool always_include_prefix = false) const; 123 wxString FormatServer(const FormatServerType formatType) const; 116 124 117 125 bool SetEncodingType(CharsetEncoding type, const wxString& encoding = wxString()); 118 126 bool SetCustomEncoding(const wxString& encoding); -
src/interface/edithandler.cpp
716 716 else 717 717 dlg.SetChildLabel(XRCID("ID_OPENEDAS"), file); 718 718 } 719 dlg.SetChildLabel(XRCID("ID_SERVER"), iter->server.FormatServer( ));719 dlg.SetChildLabel(XRCID("ID_SERVER"), iter->server.FormatServer(SERVER_USER_HOST_PORT)); 720 720 dlg.SetChildLabel(XRCID("ID_REMOTEPATH"), iter->remotePath.GetPath()); 721 721 722 722 dlg.GetSizer()->Fit(&dlg); … … 1117 1117 pListCtrl->SetItem(i, COLUMN_STATUS, _("Unknown")); 1118 1118 break; 1119 1119 } 1120 pListCtrl->SetItem(i, COLUMN_REMOTEPATH, iter->server.FormatServer( ) + iter->remotePath.GetPath());1120 pListCtrl->SetItem(i, COLUMN_REMOTEPATH, iter->server.FormatServer(SERVER_USER_HOST_PORT) + iter->remotePath.GetPath()); 1121 1121 CEditHandler::t_fileData* pData = new CEditHandler::t_fileData(*iter); 1122 1122 pListCtrl->SetItemPtrData(i, (wxUIntPtr)pData); 1123 1123 } … … 1145 1145 pListCtrl->SetItem(i, COLUMN_STATUS, _("Unknown")); 1146 1146 break; 1147 1147 } 1148 pListCtrl->SetItem(i, COLUMN_REMOTEPATH, iter->server.FormatServer( ) + iter->remotePath.GetPath());1148 pListCtrl->SetItem(i, COLUMN_REMOTEPATH, iter->server.FormatServer(SERVER_USER_HOST_PORT) + iter->remotePath.GetPath()); 1149 1149 CEditHandler::t_fileData* pData = new CEditHandler::t_fileData(*iter); 1150 1150 pListCtrl->SetItemPtrData(i, (wxUIntPtr)pData); 1151 1151 } -
src/interface/file_utils.cpp
20 20 if (!utf8) 21 21 return wxString(); 22 22 23 //TODO: create a standalone URLEncode function 23 24 const char* p = utf8; 24 25 while (*p) 25 26 { -
src/interface/loginmanager.cpp
59 59 pwdDlg.GetSizer()->Show(XRCCTRL(pwdDlg, "ID_REMEMBER", wxCheckBox), canRemember, true); 60 60 XRCCTRL(pwdDlg, "ID_CHALLENGE", wxTextCtrl)->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); 61 61 } 62 XRCCTRL(pwdDlg, "ID_HOST", wxStaticText)->SetLabel(server.Format Host());62 XRCCTRL(pwdDlg, "ID_HOST", wxStaticText)->SetLabel(server.FormatServer(SERVER_HOST_PORT)); 63 63 64 64 if (server.GetUser().empty()) { 65 65 pwdDlg.SetTitle(_("Enter username and password")); -
src/interface/Mainfrm.cpp
830 830 CSpeedLimitsDialog dlg; 831 831 dlg.Run(this); 832 832 } 833 else if (event.GetId() == XRCID("ID_MENU_EDIT_URLPASSWORD")) { 834 if (event.IsChecked()) { 835 if (wxMessageBoxEx(_("This option will enable the ability to copy password in clear in the clipboard.\nThis is insecure, are you sure you want to continue?"), _("Include password in URL"), wxICON_QUESTION | wxYES_NO) == wxYES) 836 COptions::Get()->SetOption(OPTION_PASSWORD_IN_URL, 1); 837 } 838 else 839 COptions::Get()->SetOption(OPTION_PASSWORD_IN_URL, 0); 840 } 833 841 else if (event.GetId() == m_comparisonToggleAcceleratorId) { 834 842 CState* pState = CContextManager::Get()->GetCurrentContext(); 835 843 if (!pState) -
src/interface/manual_transfer.cpp
159 159 { 160 160 if (m_pServer) 161 161 { 162 XRCCTRL(*this, "ID_HOST", wxTextCtrl)->ChangeValue(m_pServer->Format Host(true));162 XRCCTRL(*this, "ID_HOST", wxTextCtrl)->ChangeValue(m_pServer->FormatServer(SERVER_HOST_ONLY)); 163 163 unsigned int port = m_pServer->GetPort(); 164 164 165 165 if (port != CServer::GetDefaultPort(m_pServer->GetProtocol())) … … 461 461 return false; 462 462 } 463 463 464 xrc_call(*this, "ID_HOST", &wxTextCtrl::ChangeValue, server.Format Host(true));464 xrc_call(*this, "ID_HOST", &wxTextCtrl::ChangeValue, server.FormatServer(SERVER_HOST_ONLY)); 465 465 xrc_call(*this, "ID_PORT", &wxTextCtrl::ChangeValue, wxString::Format(_T("%d"), server.GetPort())); 466 466 467 467 protocolName = CServer::GetProtocolName(server.GetProtocol()); -
src/interface/menu_bar.cpp
86 86 menubar->Check(XRCID("ID_VIEW_REMOTETREE"), COptions::Get()->GetOptionVal(OPTION_SHOW_TREE_REMOTE) != 0); 87 87 menubar->Check(XRCID("ID_MENU_VIEW_FILELISTSTATUSBAR"), COptions::Get()->GetOptionVal(OPTION_FILELIST_STATUSBAR) != 0); 88 88 menubar->Check(XRCID("ID_MENU_TRANSFER_PRESERVETIMES"), COptions::Get()->GetOptionVal(OPTION_PRESERVE_TIMESTAMPS) != 0); 89 89 menubar->Check(XRCID("ID_MENU_EDIT_URLPASSWORD"), COptions::Get()->GetOptionVal(OPTION_PASSWORD_IN_URL) != 0); 90 90 91 switch (COptions::Get()->GetOptionVal(OPTION_ASCIIBINARY)) 91 92 { 92 93 case 1: … … 373 374 if (options.test(OPTION_PRESERVE_TIMESTAMPS)) { 374 375 Check(XRCID("ID_MENU_TRANSFER_PRESERVETIMES"), COptions::Get()->GetOptionVal(OPTION_PRESERVE_TIMESTAMPS) != 0); 375 376 } 377 if (options.test(OPTION_PASSWORD_IN_URL)) { 378 Check(XRCID("ID_MENU_EDIT_URLPASSWORD"), COptions::Get()->GetOptionVal(OPTION_PASSWORD_IN_URL) != 0); 379 } 376 380 if (options.test(OPTION_SHOW_TREE_LOCAL)) { 377 381 Check(XRCID("ID_VIEW_LOCALTREE"), COptions::Get()->GetOptionVal(OPTION_SHOW_TREE_LOCAL) != 0); 378 382 } -
src/interface/Options.cpp
198 198 // Default/internal options 199 199 { "Config Location", string, _T(""), default_only }, 200 200 { "Kiosk mode", number, _T("0"), default_priority }, 201 { "Disable update check", number, _T("0"), default_only } 201 { "Disable update check", number, _T("0"), default_only }, 202 { "Include passwords in URL", number, _T("0"), default_only } 202 203 }; 203 204 204 205 BEGIN_EVENT_TABLE(COptions, wxEvtHandler) -
src/interface/Options.h
98 98 OPTION_PERSISTENT_CHOICES, 99 99 OPTION_QUEUE_COMPLETION_ACTION, 100 100 OPTION_QUEUE_COMPLETION_COMMAND, 101 OPTION_PASSWORD_IN_URL, 101 102 102 103 // Default/internal options 103 104 OPTION_DEFAULT_SETTINGSDIR, // guaranteed to be (back)slash-terminated -
src/interface/queue.cpp
391 391 392 392 wxString CServerItem::GetName() const 393 393 { 394 return m_server.FormatServer( );394 return m_server.FormatServer(SERVER_USER_HOST_PORT); 395 395 } 396 396 397 397 void CServerItem::AddChild(CQueueItem* pItem) -
src/interface/quickconnectbar.cpp
86 86 return; 87 87 } 88 88 89 host = server.Format Host(true);89 host = server.FormatServer(SERVER_HOST_ONLY); 90 90 ServerProtocol protocol = server.GetProtocol(); 91 91 switch (protocol) 92 92 { … … 159 159 iter != m_recentServers.end(); 160 160 ++iter, ++i) 161 161 { 162 wxString name(iter->FormatServer( ));162 wxString name(iter->FormatServer(SERVER_USER_HOST_PORT)); 163 163 name.Replace(_T("&"), _T("&&")); 164 164 pMenu->Append(10 + i, name); 165 165 } -
src/interface/RemoteListView.cpp
2523 2523 } 2524 2524 2525 2525 const CServerPath& path = m_pDirectoryListing->path; 2526 const wxString server = pServer->FormatServer(true); 2526 2527 if (COptions::Get()->GetOptionVal(OPTION_PASSWORD_IN_URL) != 0) 2528 wxString server = pServer->FormatServer(SERVER_URL_PASSWORD) 2529 else 2530 wxString server = pServer->FormatServer(SERVER_URL); 2531 2527 2532 if (selected_item_list.size() == 1) 2528 2533 { 2529 2534 wxString url = server; … … 2530 2535 url += path.FormatFilename(selected_item_list.front().name, false); 2531 2536 2532 2537 // Poor mans URLencode 2538 // TODO: use a proper URLEncode function, confer file_utils.cpp 2533 2539 url.Replace(_T(" "), _T("%20")); 2534 2540 2535 2541 wxTheClipboard->SetData(new wxURLDataObject(url)); … … 2549 2555 } 2550 2556 2551 2557 // Poor mans URLencode 2558 // TODO: use a proper URLEncode function, confer file_utils.cpp 2552 2559 urls.Replace(_T(" "), _T("%20")); 2553 2560 2554 2561 wxTheClipboard->SetData(new wxTextDataObject(urls)); -
src/interface/RemoteTreeView.cpp
1382 1382 return; 1383 1383 } 1384 1384 1385 wxString url = pServer->FormatServer(true); 1385 if (COptions::Get()->GetOptionVal(OPTION_PASSWORD_IN_URL) != 0) 1386 wxString url = pServer->FormatServer(SERVER_URL_PASSWORD) 1387 else 1388 wxString url = pServer->FormatServer(SERVER_URL); 1389 1386 1390 url += path.GetPath(); 1387 1391 1388 1392 // Poor mans URLencode 1393 // TODO: use a proper URLEncode function, confer file_utils.cpp 1389 1394 url.Replace(_T(" "), _T("%20")); 1390 1395 1391 1396 wxTheClipboard->SetData(new wxURLDataObject(url)); -
src/interface/resources/xrc/menus.xrc
49 49 <object class="wxMenuItem" name="ID_MENU_EDIT_CLEARPRIVATEDATA"> 50 50 <label>&Clear private data...</label> 51 51 </object> 52 <object class="wxMenuItem" name="ID_MENU_EDIT_URLPASSWORD"> 53 <label>Show &password in URL...</label> 54 <checkable>1</checkable> 55 </object> 52 56 <object class="separator"/> 53 57 <object class="wxMenuItem" name="wxID_PREFERENCES"> 54 58 <label>&Settings...</label> -
src/interface/sitemanager_dialog.cpp
1000 1000 return false; 1001 1001 } 1002 1002 1003 XRCCTRL(*this, "ID_HOST", wxTextCtrl)->ChangeValue(server.Format Host(true));1003 XRCCTRL(*this, "ID_HOST", wxTextCtrl)->ChangeValue(server.FormatServer(SERVER_HOST_ONLY)); 1004 1004 if (server.GetPort() != CServer::GetDefaultPort(server.GetProtocol())) { 1005 1005 XRCCTRL(*this, "ID_PORT", wxTextCtrl)->ChangeValue(wxString::Format(_T("%d"), server.GetPort())); 1006 1006 } … … 1623 1623 xrc_call(*this, "ID_CONNECT", &wxButton::Enable, true); 1624 1624 1625 1625 xrc_call(*this, "ID_HOST", &wxWindow::Enable, !predefined); 1626 xrc_call(*this, "ID_HOST", &wxTextCtrl::ChangeValue, site_data->m_server.Format Host(true));1626 xrc_call(*this, "ID_HOST", &wxTextCtrl::ChangeValue, site_data->m_server.FormatServer(SERVER_HOST_ONLY)); 1627 1627 unsigned int port = site_data->m_server.GetPort(); 1628 1628 1629 1629 if (port != CServer::GetDefaultPort(site_data->m_server.GetProtocol())) -
src/interface/state.cpp
469 469 470 470 const wxString& name = server->GetName(); 471 471 if (!name.empty()) 472 m_title = name + _T(" - ") + server->FormatServer( );472 m_title = name + _T(" - ") + server->FormatServer(SERVER_USER_HOST_PORT); 473 473 else 474 m_title = server->FormatServer( );474 m_title = server->FormatServer(SERVER_USER_HOST_PORT); 475 475 } 476 476 else { 477 477 m_pServer = 0; -
src/interface/statuslinectrl.cpp
240 240 m_statusText = _("Waiting for transfer to be cancelled"); 241 241 break; 242 242 case t_EngineData::connect: 243 m_statusText = wxString::Format(_("Connecting to %s"), m_pEngineData->lastServer.FormatServer( ));243 m_statusText = wxString::Format(_("Connecting to %s"), m_pEngineData->lastServer.FormatServer(SERVER_USER_HOST_PORT)); 244 244 break; 245 245 default: 246 246 m_statusText = _("Transferring");