diff Core/HttpServer/HttpOutput.cpp @ 3616:b6a569e6e85b

author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 23 Jan 2020 12:58:08 +0100
parents f6fe095f7130
children 94f4a18a79cc
line wrap: on
line diff
--- a/Core/HttpServer/HttpOutput.cpp	Thu Jan 16 12:50:06 2020 +0100
+++ b/Core/HttpServer/HttpOutput.cpp	Thu Jan 23 12:58:08 2020 +0100
@@ -463,6 +463,21 @@
     }
 
     boundary = Toolbox::GenerateUuid() + "-" + Toolbox::GenerateUuid();
+
+    /**
+     * Fix for issue #165: "Encapsulation boundaries must not appear
+     * within the encapsulations, and must be no longer than 70
+     * characters, not counting the two leading hyphens."
+     * https://tools.ietf.org/html/rfc1521
+     * https://bitbucket.org/sjodogne/orthanc/issues/165/
+     **/
+    if (boundary.size() != 36 + 1 + 36)  // one UUID contains 36 characters
+    {
+      throw OrthancException(ErrorCode_InternalError);
+    }
+    
+    boundary = boundary.substr(0, 70);
+    
     contentTypeHeader = ("multipart/" + subType + "; type=" + tmp + "; boundary=" + boundary);
   }