diff --git a/interfaces/common/src/sandbox_helper.cpp b/interfaces/common/src/sandbox_helper.cpp index e15b6c1d7f9fe8c5f283112760aa1504aa7296e0..312029e791e829a398cf4742f724b4561d6d38ba 100644 --- a/interfaces/common/src/sandbox_helper.cpp +++ b/interfaces/common/src/sandbox_helper.cpp @@ -48,6 +48,9 @@ namespace { const string LOCAL = "local"; const int ASSET_IN_BUCKET_NUM_MAX = 1000; const int ASSET_DIR_START_NUM = 16; + const int32_t DECODE_LEN = 2; + string deCodeInPutUri = ""; + string deCodeOutPutUri = ""; } struct MediaUriInfo { @@ -87,23 +90,26 @@ string SandboxHelper::Encode(const string &uri) string SandboxHelper::Decode(const string &uri) { + if (uri == deCodeInPutUri) { + return deCodeOutPutUri; + } std::ostringstream outPutStream; - const int32_t encodeLen = 2; size_t index = 0; while (index < uri.length()) { if (uri[index] == '%') { int hex = 0; - std::istringstream inputStream(uri.substr(index + 1, encodeLen)); + std::istringstream inputStream(uri.substr(index + 1, DECODE_LEN)); inputStream >> std::hex >> hex; outPutStream << static_cast(hex); - index += encodeLen + 1; + index += DECODE_LEN + 1; } else { outPutStream << uri[index]; index++; } } - - return outPutStream.str(); + deCodeInPutUri = uri; + deCodeOutPutUri = outPutStream.str(); + return deCodeOutPutUri; } static string GetLowerPath(string &lowerPathHead, const string &lowerPathTail,