diff options
Diffstat (limited to 'ShellPkg/Library/UefiShellLib')
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.c | 55 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.h | 18 |
2 files changed, 71 insertions, 2 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 819c9f03ac..dc36db0349 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -1494,6 +1494,7 @@ ShellOpenFileMetaArg ( {
EFI_STATUS Status;
LIST_ENTRY mOldStyleFileList;
+ CHAR16 *CleanFilePathStr;
//
// ASSERT that Arg and ListHead are not NULL
@@ -1501,6 +1502,11 @@ ShellOpenFileMetaArg ( ASSERT(Arg != NULL);
ASSERT(ListHead != NULL);
+ Status = InternalShellStripQuotes (Arg, &CleanFilePathStr);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
//
// Check for UEFI Shell 2.0 protocols
//
@@ -1508,11 +1514,12 @@ ShellOpenFileMetaArg ( if (*ListHead == NULL) {
*ListHead = (EFI_SHELL_FILE_INFO*)AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
if (*ListHead == NULL) {
+ FreePool(CleanFilePathStr);
return (EFI_OUT_OF_RESOURCES);
}
InitializeListHead(&((*ListHead)->Link));
}
- Status = gEfiShellProtocol->OpenFileList(Arg,
+ Status = gEfiShellProtocol->OpenFileList(CleanFilePathStr,
OpenMode,
ListHead);
if (EFI_ERROR(Status)) {
@@ -1522,9 +1529,11 @@ ShellOpenFileMetaArg ( }
if (*ListHead != NULL && IsListEmpty(&(*ListHead)->Link)) {
FreePool(*ListHead);
+ FreePool(CleanFilePathStr);
*ListHead = NULL;
return (EFI_NOT_FOUND);
}
+ FreePool(CleanFilePathStr);
return (Status);
}
@@ -1540,15 +1549,17 @@ ShellOpenFileMetaArg ( //
// Get the EFI Shell list of files
//
- Status = mEfiShellEnvironment2->FileMetaArg(Arg, &mOldStyleFileList);
+ Status = mEfiShellEnvironment2->FileMetaArg(CleanFilePathStr, &mOldStyleFileList);
if (EFI_ERROR(Status)) {
*ListHead = NULL;
+ FreePool(CleanFilePathStr);
return (Status);
}
if (*ListHead == NULL) {
*ListHead = (EFI_SHELL_FILE_INFO *)AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
if (*ListHead == NULL) {
+ FreePool(CleanFilePathStr);
return (EFI_OUT_OF_RESOURCES);
}
InitializeListHead(&((*ListHead)->Link));
@@ -1569,9 +1580,11 @@ ShellOpenFileMetaArg ( *ListHead = NULL;
Status = EFI_NOT_FOUND;
}
+ FreePool(CleanFilePathStr);
return (Status);
}
+ FreePool(CleanFilePathStr);
return (EFI_UNSUPPORTED);
}
/**
@@ -4240,3 +4253,41 @@ ShellDeleteFileByName( return(Status);
}
+
+/**
+ Cleans off all the quotes in the string.
+
+ @param[in] OriginalString pointer to the string to be cleaned.
+ @param[out] CleanString The new string with all quotes removed.
+ Memory allocated in the function and free
+ by caller.
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
+EFI_STATUS
+EFIAPI
+InternalShellStripQuotes (
+ IN CONST CHAR16 *OriginalString,
+ OUT CHAR16 **CleanString
+ )
+{
+ CHAR16 *Walker;
+
+ if (OriginalString == NULL || CleanString == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *CleanString = AllocateCopyPool (StrSize (OriginalString), OriginalString);
+ if (*CleanString == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {
+ if (*Walker == L'\"') {
+ CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.h b/ShellPkg/Library/UefiShellLib/UefiShellLib.h index 32f1c6596d..c70e6cb91e 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.h +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.h @@ -72,5 +72,23 @@ InternalShellIsHexOrDecimalNumber ( IN CONST BOOLEAN StopAtSpace
);
+/**
+ Cleans off all the quotes in the string.
+
+ @param[in] OriginalString pointer to the string to be cleaned.
+ @param[out] CleanString The new string with all quotes removed.
+ Memory allocated in the function and free
+ by caller.
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
+EFI_STATUS
+EFIAPI
+InternalShellStripQuotes (
+ IN CONST CHAR16 *OriginalString,
+ OUT CHAR16 **CleanString
+ );
+
+
#endif
|