comparison Core/WebServiceParameters.cpp @ 4085:da06381f3091

backporting fix from framework branch to mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 25 Jun 2020 15:11:41 +0200
parents ae0e3fd609df
children
comparison
equal deleted inserted replaced
4084:25812a487037 4085:da06381f3091
41 41
42 #if ORTHANC_SANDBOXED == 0 42 #if ORTHANC_SANDBOXED == 0
43 # include "SystemToolbox.h" 43 # include "SystemToolbox.h"
44 #endif 44 #endif
45 45
46 #include <boost/algorithm/string/find.hpp>
46 #include <cassert> 47 #include <cassert>
47 48
48 namespace Orthanc 49 namespace Orthanc
49 { 50 {
50 static const char* KEY_CERTIFICATE_FILE = "CertificateFile"; 51 static const char* KEY_CERTIFICATE_FILE = "CertificateFile";
87 } 88 }
88 89
89 90
90 void WebServiceParameters::SetUrl(const std::string& url) 91 void WebServiceParameters::SetUrl(const std::string& url)
91 { 92 {
92 if (!Toolbox::StartsWith(url, "http://") && 93 if (boost::find_first(url, "://"))
93 !Toolbox::StartsWith(url, "https://")) 94 {
94 { 95 // Only allow the HTTP and HTTPS protocols
95 throw OrthancException(ErrorCode_BadFileFormat, "Bad URL: " + url); 96 if (!Toolbox::StartsWith(url, "http://") &&
97 !Toolbox::StartsWith(url, "https://"))
98 {
99 throw OrthancException(ErrorCode_BadFileFormat, "Bad URL: " + url);
100 }
101 }
102
103 if (url.empty())
104 {
105 throw OrthancException(ErrorCode_BadFileFormat, "Empty URL");
96 } 106 }
97 107
98 // Add trailing slash if needed 108 // Add trailing slash if needed
99 if (url[url.size() - 1] == '/') 109 if (url[url.size() - 1] == '/')
100 { 110 {