diff --git a/checkin_notes b/checkin_notes index a9783b6b97..7869cf96b1 100755 --- a/checkin_notes +++ b/checkin_notes @@ -15014,3 +15014,21 @@ David 9 July 2004 gui_test.C tools/ create_work.C + +David 11 July 2004 + - changes in core client related to attaching to projects + - commented out "maybe_rename_old_filename_format()" stuff. + Not needed, and contains hazardous asserts + - CLIENT_STATE::add_project() + - check that master URL starts with http://, + and has other chars after that + [WHY WASN'T THIS BEING DONE??] + - check that authenticator is non-null + + client/ + cs_account.C + win/ + wingui_dialog.cpp + lib/ + error_numbers.h + util.C,h diff --git a/client/cs_account.C b/client/cs_account.C index 019837d5c0..a56302d50e 100644 --- a/client/cs_account.C +++ b/client/cs_account.C @@ -35,7 +35,8 @@ using std::string; -static inline string filename_to_project_dirname(const string& filename) { +#if 0 +static string filename_to_project_dirname(const string& filename) { assert(starts_with(filename, "account_")); assert(ends_with(filename, ".xml")); return string(PROJECTS_DIR) + PATH_SEPARATOR + filename.substr(8,filename.size()-12); @@ -66,6 +67,7 @@ static bool maybe_rename_old_filename_format(string& filename) { } return false; } +#endif int CLIENT_STATE::parse_account_files() { string name; @@ -75,10 +77,12 @@ int CLIENT_STATE::parse_account_files() { DirScanner dir("."); while (dir.scan(name)) { if (is_account_file((char*)name.c_str())) { +#if 0 if (maybe_rename_old_filename_format(name)) { msg_printf(NULL, MSG_ERROR, "Warning: not adding project %s", name.c_str()); continue; // Error occurred renaming } +#endif f = fopen(name.c_str(), "r"); if (!f) continue; project = new PROJECT; @@ -90,14 +94,26 @@ int CLIENT_STATE::parse_account_files() { return 0; } -int CLIENT_STATE::add_project(const char* master_url, const char* authenticator) { - char path[256], canonical_master_url[256]; +int CLIENT_STATE::add_project(const char* master_url, const char* _auth) { + char path[256], canonical_master_url[256], auth[256]; PROJECT* project; FILE* f; int retval; safe_strcpy(canonical_master_url, master_url); + strip_whitespace(canonical_master_url); canonicalize_master_url(canonical_master_url); + if (invalid_url(canonical_master_url)) { + msg_printf(0, MSG_ERROR, "Invalid project URL: %s", canonical_master_url); + return ERR_INVALID_URL; + } + + safe_strcpy(auth, _auth); + strip_whitespace(auth); + if (!strlen(auth)) { + msg_printf(0, MSG_ERROR, "Invalid account ID: %s", auth); + return ERR_AUTHENTICATOR; + } // check if this project is already running // @@ -110,8 +126,7 @@ int CLIENT_STATE::add_project(const char* master_url, const char* authenticator) // project = new PROJECT; strcpy(project->master_url, canonical_master_url); - strcpy(project->authenticator, authenticator); - strip_whitespace(project->authenticator); + strcpy(project->authenticator, auth); project->tentative = true; retval = project->write_account_file(); diff --git a/client/win/wingui_dialog.cpp b/client/win/wingui_dialog.cpp index b665edae81..b3bac45308 100755 --- a/client/win/wingui_dialog.cpp +++ b/client/win/wingui_dialog.cpp @@ -63,7 +63,7 @@ BOOL CLoginDialog::OnInitDialog() { CDialog::OnInitDialog(); m_strUrlTT.Format("The URL for the website of the project."); - m_strAuthTT.Format("The authorization code received in your confirmation email."); + m_strAuthTT.Format("The account ID received in your confirmation email."); LoadLanguage(); CWnd* pWndUrl = GetDlgItem(IDC_LOGIN_URL); if(pWndUrl) { diff --git a/lib/error_numbers.h b/lib/error_numbers.h index e20b862c76..19d291b115 100755 --- a/lib/error_numbers.h +++ b/lib/error_numbers.h @@ -136,4 +136,4 @@ #define ERR_RESULT_START -185 #define ERR_RESULT_DOWNLOAD -186 #define ERR_RESULT_UPLOAD -187 - +#define ERR_INVALID_URL -189 diff --git a/lib/util.C b/lib/util.C index 60d8bf3770..e0dc7088ca 100755 --- a/lib/util.C +++ b/lib/util.C @@ -457,6 +457,12 @@ void canonicalize_master_url(char *xurl) { strcpy(xurl, url.c_str()); } +bool invalid_url(char* p) { + if (strstr(p, "http://") != p) return true; + if (strlen(p) == strlen("http://")) return true; + return false; +} + void safe_strncpy(char* dst, const char* src, int len) { strncpy(dst, src, len); dst[len-1]=0; diff --git a/lib/util.h b/lib/util.h index 4e21b7f3c4..51beafd689 100755 --- a/lib/util.h +++ b/lib/util.h @@ -48,6 +48,7 @@ extern void strip_whitespace(std::string&); extern void unescape_url(char *url); extern void escape_url(char *in, char*out); extern void escape_url_readable(char* in, char* out); +extern bool invalid_url(char*); extern void canonicalize_master_url(char *url); extern void safe_strncpy(char*, const char*, int); #define safe_strcpy(x, y) safe_strncpy(x, y, sizeof(x))