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

@@ -743,8 +743,12 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
{
Logger.Write(TraceEventType.Verbose, "HandleRebuildIntelliSenseNotification");
// 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 escapedOwnerUri = Uri.EscapeUriString(rebuildParams.OwnerUri);
// Skip closing this file if the file doesn't exist
var scriptFile = this.CurrentWorkspace.GetFile(rebuildParams.OwnerUri);
var scriptFile = this.CurrentWorkspace.GetFile(escapedOwnerUri);
if (scriptFile == null)
{
return;
@@ -1078,7 +1082,11 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
{
if (scriptInfo.IsConnected)
{
var scriptFile = CurrentWorkspace.GetFile(info.OwnerUri);
// 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 fileUri = Uri.EscapeUriString(info.OwnerUri);
var scriptFile = CurrentWorkspace.GetFile(fileUri);
if (scriptFile == null)
{
return;