1 |
/* wptCommonDlg.cpp |
/* wptCommonDlg.cpp |
2 |
* Copyright (C) 2004, 2005 Timo Schulz |
* Copyright (C) 2004, 2005, 2006 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
22 |
#endif |
#endif |
23 |
|
|
24 |
#include <windows.h> |
#include <windows.h> |
25 |
|
#include <ctype.h> |
26 |
|
|
27 |
#include "resource.h" |
#include "resource.h" |
28 |
|
|
38 |
static int |
static int |
39 |
check_URL (const char *buf) |
check_URL (const char *buf) |
40 |
{ |
{ |
41 |
/* XXX: be more strict */ |
size_t i; |
42 |
|
const char *allowed = "-./#_:"; |
43 |
|
|
44 |
|
if (strncmp (buf, "http://", 7)) |
45 |
|
return -1; |
46 |
if (!strchr (buf, ':')) |
if (!strchr (buf, ':')) |
47 |
return -1; |
return -1; |
48 |
if (!strstr (buf, "//")) |
if (!strstr (buf, "//")) |
49 |
return -1; |
return -1; |
50 |
|
if (strstr (buf, " ")) |
51 |
|
return -1; |
52 |
|
buf += 7; |
53 |
|
for (i=0; i < strlen (buf); i++) { |
54 |
|
if (isalpha (buf[i]) || isdigit (buf[i])) |
55 |
|
continue; |
56 |
|
if (!strchr (allowed, buf[i])) |
57 |
|
return -1; |
58 |
|
} |
59 |
|
|
60 |
return 0; |
return 0; |
61 |
} |
} |
62 |
|
|
74 |
BUG (0); |
BUG (0); |
75 |
if (ctx->desc != NULL) |
if (ctx->desc != NULL) |
76 |
SetWindowText (dlg, ctx->desc); |
SetWindowText (dlg, ctx->desc); |
|
else |
|
|
SetWindowText (dlg, _("HTTP Key Import")); |
|
77 |
if (ctx->title != NULL) |
if (ctx->title != NULL) |
78 |
SetDlgItemText (dlg, IDC_HTTP_TITLE, ctx->title); |
SetDlgItemText (dlg, IDC_HTTP_TITLE, ctx->title); |
|
else |
|
|
SetDlgItemText (dlg, IDC_HTTP_TITLE, _("Enter URL to retrieve the public key")); |
|
79 |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
80 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
81 |
break; |
break; |
114 |
if (!ctx) |
if (!ctx) |
115 |
BUG (0); |
BUG (0); |
116 |
memset (ctx, 0, sizeof *ctx); |
memset (ctx, 0, sizeof *ctx); |
117 |
ctx->check = 1; |
ctx->check = 1; |
118 |
|
ctx->desc = _("HTTP Key Import"); |
119 |
|
ctx->title = _("Enter URL to retrieve the public key"); |
120 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_HTTP, root, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_HTTP, root, |
121 |
http_dlg_proc, (LPARAM)ctx); |
http_dlg_proc, (LPARAM)ctx); |
122 |
return ctx; |
return ctx; |