[Verification] Code compiles, pass rate: 116/140.
Change-Id: Ic3a4133b800e315c8df396d234ab3f6adb978e61
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
var parent_path = absolute_path.substring(0, absolute_path.lastIndexOf('/'));
var child_name = absolute_path.substring(absolute_path.lastIndexOf('/') + 1);
- // http://www.w3.org/TR/2011/WD-file-system-api-20110419/#naming-restrictions
- var disallowedCharacters = [ '/', '\\', '<', '>', ':', '?', '*', '"', '|' ];
-
- for (var i = 0; i < disallowedCharacters.length; ++i) {
- if (-1 !== child_name.indexOf(disallowedCharacters[i])) {
- console.error('File name contains disallowed character: ' + disallowedCharacters[i]);
- errorCallback && errorCallback(FileError.ENCODING_ERR);
- return;
- }
+ if (!rootsUtils.isValidFileName(child_name)) {
+ console.error('Disallowed character detected in file name: ' + child_name);
+ errorCallback && errorCallback(FileError.ENCODING_ERR);
+ return;
}
var resolveSuccess = function(dir) {
var name = args[2];
var destURL = args[1] + ((args[1][args[1].length-1] === '/') ? '' : '/') + name;
+ if (!rootsUtils.isValidFileName(name)) {
+ console.error('Disallowed character detected in file name: ' + name);
+ errorCallback && errorCallback(FileError.ENCODING_ERR);
+ return;
+ }
+
resolveParent (srcURL, errorCallback,
function(srcFile, parentDir) {
try {
return (fs.fullPath === getFullPath(uri));
}
+ // http://www.w3.org/TR/2011/WD-file-system-api-20110419/#naming-restrictions
+ var disallowedCharacters = [ '/', '\\', '<', '>', ':', '?', '*', '"', '|' ];
+
+ function isValidFileName(name) {
+ for (var i = 0; i < disallowedCharacters.length; ++i) {
+ if (-1 !== name.indexOf(disallowedCharacters[i])) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
return {
getRoots: getRoots,
findFilesystem: findFilesystem,
getNativeUrl: getNativeUrl,
stripTrailingSlash: stripTrailingSlash,
createEntry: createEntry,
- isRootUri: isRootUri
+ isRootUri: isRootUri,
+ isValidFileName: isValidFileName
};
})();