Esempio n. 1
0
        /// <summary>
        /// Builds local file system file path from the Uri data
        /// </summary>
        private string GetFilePathFromUri(Uri uri)
        {
            var filePath = Path.Combine(_options.Value.AssetsCacheFolder, uri.Host, SecurityUtility.GetHash(uri.AbsoluteUri));

            if (!SecurityUtility.IsInsidePath(_options.Value.AssetsCacheFolder, filePath)) //Impossible really, but ...
            {
                throw new InvalidUriException(string.Format("Invalid request and attempt to access outside Cache folder with the url {0}.", uri.AbsoluteUri));
            }

            return(filePath);
        }