Skip to content

Commit d5bfd9a

Browse files
authored
Merge pull request #6176 from BOINC/dpa_www2
2 parents f8dbe6d + 487c8dc commit d5bfd9a

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

client/client_state.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,22 +1267,29 @@ bool CLIENT_STATE::poll_slow_events() {
12671267
#endif // ifndef SIM
12681268

12691269
// Find the project with the given master_url.
1270-
// Ignore differences in protocol, case, and trailing /
1270+
// Ignore differences in protocol, case, leading 'www.', and trailing /
1271+
// (the URL could come from an account manager,
1272+
// with differences from the real URL)
12711273
//
12721274
PROJECT* CLIENT_STATE::lookup_project(const char* master_url) {
12731275
char buf[256];
12741276

12751277
safe_strcpy(buf, master_url);
12761278
canonicalize_master_url(buf, sizeof(buf));
1277-
char* p = strstr(buf, "//");
1279+
const char* p = strstr(buf, "//");
12781280
if (!p) return NULL;
1281+
p += 2;
1282+
if (strcasestr(p, "www.") == p) p += 4;
1283+
strcpy(buf, p);
12791284

1280-
for (unsigned int i=0; i<projects.size(); i++) {
1281-
char* q = strstr(projects[i]->master_url, "//");
1285+
for (PROJECT *project: projects) {
1286+
const char* q = strstr(project->master_url, "//");
12821287
if (!q) continue;
1283-
if (!strcasecmp(p, q)) {
1288+
q += 2;
1289+
if (strcasestr(q, "www.") == q) q += 4;
1290+
if (!strcasecmp(buf, q)) {
12841291
// note: canonicalize_master_url() doesn't lower-case
1285-
return projects[i];
1292+
return project;
12861293
}
12871294
}
12881295
return 0;

lib/url.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ void escape_url_readable(char *in, char* out) {
203203
// Canonicalize a master url.
204204
// - Prepend http:// if protocol missing
205205
// - Remove double slashes in the rest
206-
// - strip leading 'www.'
207206
// - Add a trailing slash if necessary
208207
// - Convert all alphabetic characters to lower case
209208
//
@@ -220,11 +219,6 @@ void canonicalize_master_url(char* url, int len) {
220219
strlcpy(buf, url, sizeof(buf));
221220
}
222221

223-
// strip leading www.
224-
//
225-
if (strstr(buf, "www.") == buf) {
226-
strcpy(buf, buf+4);
227-
}
228222
while (1) {
229223
p = strstr(buf, "//");
230224
if (!p) break;

0 commit comments

Comments
 (0)