Mercurial > hg > orthanc
changeset 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 | 25812a487037 |
children | 4cd94ed75a5b |
files | Core/WebServiceParameters.cpp |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/WebServiceParameters.cpp Thu Jun 25 08:28:11 2020 +0200 +++ b/Core/WebServiceParameters.cpp Thu Jun 25 15:11:41 2020 +0200 @@ -43,6 +43,7 @@ # include "SystemToolbox.h" #endif +#include <boost/algorithm/string/find.hpp> #include <cassert> namespace Orthanc @@ -89,10 +90,19 @@ void WebServiceParameters::SetUrl(const std::string& url) { - if (!Toolbox::StartsWith(url, "http://") && - !Toolbox::StartsWith(url, "https://")) + if (boost::find_first(url, "://")) { - throw OrthancException(ErrorCode_BadFileFormat, "Bad URL: " + url); + // Only allow the HTTP and HTTPS protocols + if (!Toolbox::StartsWith(url, "http://") && + !Toolbox::StartsWith(url, "https://")) + { + throw OrthancException(ErrorCode_BadFileFormat, "Bad URL: " + url); + } + } + + if (url.empty()) + { + throw OrthancException(ErrorCode_BadFileFormat, "Empty URL"); } // Add trailing slash if needed