[Exif] TCT fixes
authorRafal Galka <r.galka@samsung.com>
Wed, 4 Mar 2015 14:23:39 +0000 (15:23 +0100)
committerPawel Sikorski <p.sikorski@samsung.com>
Mon, 9 Mar 2015 13:31:11 +0000 (22:31 +0900)
[Verification]
TCT result 100% (63/63)

Change-Id: I4cf2ab45ee8b2ef045c42418a8d9335e0d202892

src/exif/exif_api.js
src/exif/exif_util.cc
src/exif/exif_util.h

index 824da3cd93bf2a14357e91ff1e4a9e2c5e86d074..c91b32d77c499974a6a32c5c287efd698340dede 100644 (file)
@@ -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);
index 030b8450345976e845a59f2e38abc93672f94c39..f5735fab7b2c582c5af631cbfcbf8528f7bfc759 100644 (file)
@@ -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
index c461dab7f88ae450668e70934d758839ff28e6ec..65328764f00351b5f680ac9b24d4ae8eef0ca5ab 100644 (file)
@@ -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);