From a00d1e3a9b1a51a9fdd9169e4363c735b31e185b Mon Sep 17 00:00:00 2001 From: Rafal Galka Date: Wed, 4 Mar 2015 15:23:39 +0100 Subject: [PATCH] [Exif] TCT fixes [Verification] TCT result 100% (63/63) Change-Id: I4cf2ab45ee8b2ef045c42418a8d9335e0d202892 --- src/exif/exif_api.js | 38 ++++++++++++++++++++++++++++++++------ src/exif/exif_util.cc | 5 ----- src/exif/exif_util.h | 2 -- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/exif/exif_api.js b/src/exif/exif_api.js index 824da3cd..c91b32d7 100644 --- a/src/exif/exif_api.js +++ b/src/exif/exif_api.js @@ -59,6 +59,12 @@ var propertiesList = { USER_COMMENT: 'userComment' }; +var URI_ABSOLUTE_PREFIX = "file:///"; + +function _isValidAbsoluteURI(uri) { + return 0 === uri.indexOf(URI_ABSOLUTE_PREFIX); +} + function _getJsonFromExifInformation(exifInfo) { var json = {}; @@ -172,6 +178,15 @@ ExifManager.prototype.getExifInfo = function() { } ]); + if (!_isValidAbsoluteURI(args.uri)) { + setTimeout(function() { + native_.callIfPossible(args.errorCallback, new tizen.WebAPIException( + tizen.WebAPIException.INVALID_VALUES_ERR, + 'Invalid URI.')); + }, 0); + return; + } + var callback = function(result) { if (native_.isFailure(result)) { native_.callIfPossible(args.errorCallback, native_.getErrorObject(result)); @@ -189,8 +204,6 @@ ExifManager.prototype.getExifInfo = function() { } }; - // TODO: Check if uri is correct (invalid characters) - // It could be done by file.resolve(uri), but at now is not implemented. tizen.filesystem.resolve(args.uri, function() { native_.call('ExifManager_getExifInfo', {'uri': args.uri}, callback); @@ -225,6 +238,15 @@ ExifManager.prototype.saveExifInfo = function() { } ]); + if (!_isValidAbsoluteURI(args.exifInfo.uri)) { + setTimeout(function() { + native_.callIfPossible(args.errorCallback, new tizen.WebAPIException( + tizen.WebAPIException.INVALID_VALUES_ERR, + 'Invalid URI.')); + }, 0); + return; + } + var json = _getJsonFromExifInformation(args.exifInfo); var callback = function(result) { if (native_.isFailure(result)) { @@ -236,7 +258,6 @@ ExifManager.prototype.saveExifInfo = function() { } }; - // TODO: check args.exifInfo.uri native_.call('ExifManager_saveExifInfo', json, callback); }; @@ -262,7 +283,14 @@ ExifManager.prototype.getThumbnail = function() { } ]); - // TODO: Check if uri contains invalid characters. It should not. + if (!_isValidAbsoluteURI(args.uri)) { + setTimeout(function() { + native_.callIfPossible(args.errorCallback, new tizen.WebAPIException( + tizen.WebAPIException.INVALID_VALUES_ERR, + 'Invalid URI.')); + }, 0); + return; + } var _callback = function(result) { if (native_.isFailure(result)) { @@ -274,8 +302,6 @@ ExifManager.prototype.getThumbnail = function() { } }; - // TODO: Check if uri is correct (invalid characters) - // It could be done by file.resolve(uri), but at now is not implemented. tizen.filesystem.resolve(args.uri, function() { native_.call('ExifManager_getThumbnail', {'uri': args.uri}, _callback); diff --git a/src/exif/exif_util.cc b/src/exif/exif_util.cc index 030b8450..f5735fab 100644 --- a/src/exif/exif_util.cc +++ b/src/exif/exif_util.cc @@ -52,7 +52,6 @@ const std::string EXPOSURE_PROGRAM_LANDSCAPE_MODE = "LANDSCAPE_MODE"; const std::string DUMMY = ""; // For unexpected input handling const std::string URI_PREFIX = "file://"; -const std::string URI_ABSOLUTE_PREFIX = "file:///"; } // namespace const std::size_t ExifTypeInfo::ByteSize = 1; @@ -215,10 +214,6 @@ const std::string& ExifUtil::exposureProgramToString(ExposureProgram value) { } } -bool ExifUtil::isValidAbsoluteURI(const std::string& uri) { - return 0 == uri.find(URI_ABSOLUTE_PREFIX); -} - // Example: // in: uri = file:///opt/usr/media/Images/exif.jpg // out: path = /opt/usr/media/Images/exif.jpg diff --git a/src/exif/exif_util.h b/src/exif/exif_util.h index c461dab7..65328764 100644 --- a/src/exif/exif_util.h +++ b/src/exif/exif_util.h @@ -119,8 +119,6 @@ class ExifUtil { const std::string& exposure_program); static const std::string& exposureProgramToString(ExposureProgram value); - static bool isValidAbsoluteURI(const std::string& uri); - static std::string convertUriToPath(const std::string& str); static std::string ltrim(const std::string& s); -- 2.34.1