diff --git a/GameRes/GameRes.cs b/GameRes/GameRes.cs index b4919857..5875b05f 100644 --- a/GameRes/GameRes.cs +++ b/GameRes/GameRes.cs @@ -140,7 +140,7 @@ namespace GameRes /// /// Extract file referenced by into current directory. /// - public virtual void Extract (ArcFile file, Entry entry) + public void Extract (ArcFile file, Entry entry) { using (var reader = OpenEntry (file, entry)) { @@ -161,20 +161,35 @@ namespace GameRes /// /// Create file corresponding to in current directory and open it - /// for writing. + /// for writing. Overwrites existing file, if any. /// public virtual Stream CreateFile (Entry entry) { - string dir = Path.GetDirectoryName (entry.Name); - if (!string.IsNullOrEmpty (dir)) + string filename = entry.Name; + string dir = Path.GetDirectoryName (filename); + if (!string.IsNullOrEmpty (dir)) // check for malformed filenames { - Directory.CreateDirectory (dir); + string root = Path.GetPathRoot (dir); + if (!string.IsNullOrEmpty (root)) + { + dir = dir.Substring (root.Length); // strip root + } + string cwd = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar; + dir = Path.GetFullPath (dir); + filename = Path.GetFileName (filename); + // check whether filename would reside within current directory + if (dir.StartsWith (cwd, StringComparison.OrdinalIgnoreCase)) + { + // path looks legit, create it + Directory.CreateDirectory (dir); + filename = Path.Combine (dir, filename); + } } - return File.Create (entry.Name); + return File.Create (filename); } /// - /// Create resource wihin stream containing entries from the + /// Create resource within stream containing entries from the /// supplied and applying necessary . /// public virtual void Create (Stream file, IEnumerable list, ResourceOptions options = null, @@ -190,7 +205,7 @@ namespace GameRes public virtual ResourceOptions GetOptions (object widget) { - return null; + return GetDefaultOptions(); } public virtual object GetCreationWidget () @@ -221,11 +236,6 @@ namespace GameRes /// public string Notice { get; set; } - /// - /// UIElement responsible for displaying request. - /// - public object InputWidget { get; set; } - /// /// Return value from ShowDialog() ///