comparison Core/Toolbox.cpp @ 1981:4b545a8b1f95

return code in Toolbox::DecodeDataUriScheme
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 22 Apr 2016 09:05:06 +0200
parents 325772dadcd6
children e29aea2349b9
comparison
equal deleted inserted replaced
1980:ebce5f456b8e 1981:4b545a8b1f95
585 result = base64_decode(data); 585 result = base64_decode(data);
586 } 586 }
587 587
588 588
589 # if BOOST_HAS_REGEX == 1 589 # if BOOST_HAS_REGEX == 1
590 void Toolbox::DecodeDataUriScheme(std::string& mime, 590 bool Toolbox::DecodeDataUriScheme(std::string& mime,
591 std::string& content, 591 std::string& content,
592 const std::string& source) 592 const std::string& source)
593 { 593 {
594 boost::regex pattern("data:([^;]+);base64,([a-zA-Z0-9=+/]*)", 594 boost::regex pattern("data:([^;]+);base64,([a-zA-Z0-9=+/]*)",
595 boost::regex::icase /* case insensitive search */); 595 boost::regex::icase /* case insensitive search */);
597 boost::cmatch what; 597 boost::cmatch what;
598 if (regex_match(source.c_str(), what, pattern)) 598 if (regex_match(source.c_str(), what, pattern))
599 { 599 {
600 mime = what[1]; 600 mime = what[1];
601 DecodeBase64(content, what[2]); 601 DecodeBase64(content, what[2]);
602 return true;
602 } 603 }
603 else 604 else
604 { 605 {
605 throw OrthancException(ErrorCode_BadFileFormat); 606 return false;
606 } 607 }
607 } 608 }
608 # endif 609 # endif
609 610
610 611