]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: parameters with spaces need quotes.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 27 Jan 2012 18:42:43 +0000 (18:42 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 27 Jan 2012 18:42:43 +0000 (18:42 +0000)
signed-off-by: jcarsey
reviewed-by: leegrosenbaum

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12960 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellLib/UefiShellLib.c

index 74f1cd3bac93412f1dc4a38c46f912e668f24ffd..aabd9140df132f98657550273085438fa0e11256 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides interface to shell functionality for shell commands and applications.\r
 \r
 /** @file\r
   Provides interface to shell functionality for shell commands and applications.\r
 \r
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -2015,15 +2015,34 @@ InternalCommandLineParse (
       //\r
       // get the item VALUE for a previous flag\r
       //\r
       //\r
       // get the item VALUE for a previous flag\r
       //\r
-      CurrentItemPackage->Value = ReallocatePool(ValueSize, ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16), CurrentItemPackage->Value);\r
-      ASSERT(CurrentItemPackage->Value != NULL);\r
-      if (ValueSize == 0) {\r
-        StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);\r
+      if (StrStr(Argv[LoopCounter], L" ") == NULL) {\r
+        CurrentItemPackage->Value = ReallocatePool(ValueSize, ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16), CurrentItemPackage->Value);\r
+        ASSERT(CurrentItemPackage->Value != NULL);\r
+        if (ValueSize == 0) {\r
+          StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);\r
+        } else {\r
+          StrCat(CurrentItemPackage->Value, L" ");\r
+          StrCat(CurrentItemPackage->Value, Argv[LoopCounter]);\r
+        }\r
+        ValueSize += StrSize(Argv[LoopCounter]) + sizeof(CHAR16);\r
       } else {\r
       } else {\r
-        StrCat(CurrentItemPackage->Value, L" ");\r
-        StrCat(CurrentItemPackage->Value, Argv[LoopCounter]);\r
+        //\r
+        // the parameter has spaces.  must be quoted.\r
+        //\r
+        CurrentItemPackage->Value = ReallocatePool(ValueSize, ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16) + sizeof(CHAR16) + sizeof(CHAR16), CurrentItemPackage->Value);\r
+        ASSERT(CurrentItemPackage->Value != NULL);\r
+        if (ValueSize == 0) {\r
+          StrCpy(CurrentItemPackage->Value, L"\"");\r
+          StrCat(CurrentItemPackage->Value, Argv[LoopCounter]);\r
+          StrCat(CurrentItemPackage->Value, L"\"");\r
+        } else {\r
+          StrCat(CurrentItemPackage->Value, L" ");\r
+          StrCat(CurrentItemPackage->Value, L"\"");\r
+          StrCat(CurrentItemPackage->Value, Argv[LoopCounter]);\r
+          StrCat(CurrentItemPackage->Value, L"\"");\r
+       }\r
+        ValueSize += StrSize(Argv[LoopCounter]) + sizeof(CHAR16);\r
       }\r
       }\r
-      ValueSize += StrSize(Argv[LoopCounter]) + sizeof(CHAR16);\r
       GetItemValue--;\r
       if (GetItemValue == 0) {\r
         InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
       GetItemValue--;\r
       if (GetItemValue == 0) {\r
         InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
@@ -2587,12 +2606,10 @@ InternalPrintTo (
     return (gEfiShellProtocol->WriteFile(gEfiShellParametersProtocol->StdOut, &Size, (VOID*)String));\r
   }\r
   if (mEfiShellInterface          != NULL) {\r
     return (gEfiShellProtocol->WriteFile(gEfiShellParametersProtocol->StdOut, &Size, (VOID*)String));\r
   }\r
   if (mEfiShellInterface          != NULL) {\r
-    if (mEfiShellInterface->RedirArgc == 0) { \r
-      //\r
-      // Divide in half for old shell.  Must be string length not size.\r
-      // \r
-      Size /=2;  // Divide in half only when no redirection.\r
-    }\r
+    //\r
+    // Divide in half for old shell.  Must be string length not size.\r
+    //\r
+    Size /= 2;\r
     return (mEfiShellInterface->StdOut->Write(mEfiShellInterface->StdOut,          &Size, (VOID*)String));\r
   }\r
   ASSERT(FALSE);\r
     return (mEfiShellInterface->StdOut->Write(mEfiShellInterface->StdOut,          &Size, (VOID*)String));\r
   }\r
   ASSERT(FALSE);\r
@@ -3647,10 +3664,10 @@ InternalShellStrHexToUint64 (
     String++;\r
 \r
     //\r
     String++;\r
 \r
     //\r
-    // Skip spaces if requested\r
+    // stop at spaces if requested\r
     //\r
     //\r
-    while (StopAtSpace && *String == L' ') {\r
-      String++;\r
+    if (StopAtSpace && *String == L' ') {\r
+      break;\r
     }\r
   }\r
 \r
     }\r
   }\r
 \r