Escape file URIs (#1189)

* Escape file URIs

* Fix test

* Add tests
This commit is contained in:
Charles Gagnon
2021-04-16 15:33:11 -07:00
committed by GitHub
parent 6fe715d2d8
commit dc6555a823
5 changed files with 37 additions and 12 deletions

View File

@@ -101,7 +101,11 @@ namespace Microsoft.SqlTools.ServiceLayer.NotebookConvert
try
{
var file = WorkspaceService<SqlToolsSettings>.Instance.Workspace.GetFile(parameters.ClientUri);
// This URI doesn't come in escaped - so if it's a file path with reserved characters (such as %)
// then we'll fail to find it since GetFile expects the URI to be a fully-escaped URI as that's
// what the document events are sent in as.
var escapedClientUri = Uri.EscapeUriString(parameters.ClientUri);
var file = WorkspaceService<SqlToolsSettings>.Instance.Workspace.GetFile(escapedClientUri);
// Temporary notebook that we just fill in with the sql until the parsing logic is added
var result = new ConvertSqlToNotebookResult
{