Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch illegal characters in ZIP exceptions #2515

Merged

Conversation

HebaruSan
Copy link
Member

Problem

If you try to install a ZIP file that contains files with names that are illegal on your OS, an exception is thrown to the unhandled exception handler:

Unhandled exception:
System.ArgumentException: Illegal characters in path.
   at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
   at System.IO.Path.IsPathRooted(String path)
   at ICSharpCode.SharpZipLib.Zip.ZipEntry.CleanName(String name)
   at ICSharpCode.SharpZipLib.Zip.ZipEntry..ctor(String name, Int32 versionRequiredToExtract, Int32 madeByInfo, CompressionMethod method)
   at ICSharpCode.SharpZipLib.Zip.ZipFile.ReadEntries()
   at ICSharpCode.SharpZipLib.Zip.ZipFile..ctor(String name)
   at CKAN.NetFileCache.ZipValid(String filename, String& invalidReason)
   at CKAN.NetModuleCache.Store(CkanModule module, String path, String description, Boolean move)
   at CKAN.NetAsyncModulesDownloader.ModuleDownloadsComplete(NetModuleCache cache, Uri[] urls, String[] filenames, Exception[] errors)
   at CKAN.NetAsyncModulesDownloader.<>c__DisplayClass8_0.<DownloadModules>b__3(Uri[] _uris, String[] paths, Exception[] errors)
   at CKAN.NetAsyncDownloader.triggerCompleted(Uri[] file_urls, String[] file_paths, Exception[] errors)
   at CKAN.NetAsyncDownloader.FileDownloadComplete(Int32 index, Exception error)
   at System.Net.WebClient.OnDownloadFileCompleted(AsyncCompletedEventArgs e)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch() 

Windows is the big offender here:

invalid characters

See #2467 for the latest example.

Changes

Now we catch System.ArgumentException in NetFileCache.ZipValid and incorporate its error message into the normal flow of handling an invalid ZIP.

Fixes #1364.

@HebaruSan HebaruSan added Windows Issues specific for Windows Pull request labels Aug 26, 2018
@politas politas merged commit 1f1fe08 into KSP-CKAN:master Oct 7, 2018
@HebaruSan HebaruSan deleted the fix/invalid-chars-in-zip-message branch October 7, 2018 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Issues specific for Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants