Mercurial > hg > orthanc
comparison Core/Toolbox.cpp @ 1988:e29aea2349b9
test validity of base64 strings
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 28 Apr 2016 17:45:03 +0200 |
parents | 4b545a8b1f95 |
children | e2dd40abce72 |
comparison
equal
deleted
inserted
replaced
1987:ce90d109bb64 | 1988:e29aea2349b9 |
---|---|
580 } | 580 } |
581 | 581 |
582 void Toolbox::DecodeBase64(std::string& result, | 582 void Toolbox::DecodeBase64(std::string& result, |
583 const std::string& data) | 583 const std::string& data) |
584 { | 584 { |
585 for (size_t i = 0; i < data.length(); i++) | |
586 { | |
587 if (!isalnum(data[i]) && | |
588 data[i] != '+' && | |
589 data[i] != '/' && | |
590 data[i] != '=') | |
591 { | |
592 // This is not a valid character for a Base64 string | |
593 throw OrthancException(ErrorCode_BadFileFormat); | |
594 } | |
595 } | |
596 | |
585 result = base64_decode(data); | 597 result = base64_decode(data); |
586 } | 598 } |
587 | 599 |
588 | 600 |
589 # if BOOST_HAS_REGEX == 1 | 601 # if BOOST_HAS_REGEX == 1 |