Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.5 KiB

  1. #include "stock.h"
  2. #pragma hdrstop
  3. #include <idhidden.h>
  4. #include <regitemp.h>
  5. #include <shstr.h>
  6. #include <shlobjp.h>
  7. #include <lmcons.h>
  8. #include <validc.h>
  9. #include "ccstock2.h"
  10. // Alpha platform doesn't need unicode thunks, seems like this
  11. // should happen automatically in the headerfiles...
  12. //
  13. #if defined(_X86_) || defined(UNIX)
  14. #else
  15. #define NO_W95WRAPS_UNITHUNK
  16. #endif
  17. #include "wininet.h"
  18. #include "w95wraps.h"
  19. // Put stuff to clean up URLs from being spoofed here.
  20. // We don't want to show escaped host names
  21. // We don't want display the username:password combo that's embedded in the url, in the UI.
  22. // So we remove those pieces, and reconstruct the url.
  23. STDAPI_(void) SHCleanupUrlForDisplay(LPTSTR pszUrl)
  24. {
  25. switch (GetUrlScheme(pszUrl))
  26. {
  27. case URL_SCHEME_FTP:
  28. case URL_SCHEME_HTTP:
  29. case URL_SCHEME_HTTPS:
  30. {
  31. URL_COMPONENTS uc = { 0 };
  32. TCHAR szName[INTERNET_MAX_URL_LENGTH];
  33. uc.dwStructSize = sizeof(uc);
  34. uc.dwSchemeLength = uc.dwHostNameLength = uc.dwUserNameLength = uc.dwPasswordLength = uc.dwUrlPathLength = uc.dwExtraInfoLength = 1;
  35. if (InternetCrackUrl(pszUrl, 0, 0, &uc) && uc.lpszHostName)
  36. {
  37. BOOL fRecreate = FALSE;
  38. for (DWORD dw=0; dw < uc.dwHostNameLength; dw++)
  39. {
  40. if (uc.lpszHostName[dw]==TEXT('%'))
  41. {
  42. URL_COMPONENTS uc2 = { 0 };
  43. uc2.dwStructSize = sizeof(uc2);
  44. uc2.dwHostNameLength = ARRAYSIZE(szName);
  45. uc2.lpszHostName = szName;
  46. if (InternetCrackUrl(pszUrl, 0, 0, &uc2))
  47. {
  48. uc.dwHostNameLength = 0;
  49. uc.lpszHostName = szName;
  50. fRecreate = TRUE;
  51. }
  52. break;
  53. }
  54. }
  55. if (uc.lpszUserName || uc.lpszPassword)
  56. {
  57. uc.dwPasswordLength = uc.dwUserNameLength = 0;
  58. uc.lpszUserName = uc.lpszPassword = NULL;
  59. fRecreate = TRUE;
  60. }
  61. if (fRecreate)
  62. {
  63. // The length of the url will be shorter than the original
  64. DWORD cc = lstrlen(pszUrl) + 1;
  65. InternetCreateUrl(&uc, 0, pszUrl, &cc);
  66. }
  67. }
  68. break;
  69. }
  70. default:
  71. break;
  72. }
  73. }