diff options
author | Tapan Shah <tapandshah@hp.com> | 2015-06-03 20:34:48 +0000 |
---|---|---|
committer | jcarsey <jcarsey@Edk2> | 2015-06-03 20:34:48 +0000 |
commit | 307f2ce4e8e70f9ec5fed8b0609ff1f613abfdc6 (patch) | |
tree | 12322a539d286b1e991595b2ec8aa2fb37a9fc8f /ShellPkg | |
parent | 421fbf99f82f6925c395cbd25821ccec09582b6b (diff) | |
download | edk2-platforms-307f2ce4e8e70f9ec5fed8b0609ff1f613abfdc6.tar.xz |
ShellPkg: Handle escape characters properly for parse command
parse command does not remove escape character ^ if used to pass special characters like ^ , “ in a quoted -sfo output string.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Tapan Shah <tapandshah@hp.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17556 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c index 545b7af342..687ced6b63 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c @@ -189,6 +189,52 @@ ParseReturnStdInLine ( }
/**
+ Handle stings for SFO Output with escape character ^ in a string
+ 1. Quotation marks in the string must be escaped by using a ^ character (i.e. ^”).
+ 2. The ^ character may be inserted using ^^.
+
+ @param[in] String The Unicode NULL-terminated string.
+
+ @retval NewString The new string handled for SFO.
+**/
+EFI_STRING
+HandleStringWithEscapeCharForParse (
+ IN CHAR16 *String
+ )
+{
+ EFI_STRING NewStr;
+ EFI_STRING StrWalker;
+ EFI_STRING ReturnStr;
+
+ if (String == NULL) {
+ return NULL;
+ }
+
+ //
+ // start to parse the input string.
+ //
+ NewStr = AllocateZeroPool (StrSize (String));
+ if (NewStr == NULL) {
+ return NULL;
+ }
+ ReturnStr = NewStr;
+ StrWalker = String;
+ while (*StrWalker != CHAR_NULL) {
+ if (*StrWalker == L'^' && (*(StrWalker + 1) == L'^' || *(StrWalker + 1) == L'"')) {
+ *NewStr = *(StrWalker + 1);
+ StrWalker++;
+ } else {
+ *NewStr = *StrWalker;
+ }
+ StrWalker++;
+ NewStr++;
+ }
+
+ return ReturnStr;
+}
+
+
+/**
Do the actual parsing of the file. the file should be SFO output from a
shell command or a similar format.
@@ -222,6 +268,7 @@ PerformParsing( CHAR16 *ColumnPointer;
SHELL_STATUS ShellStatus;
CHAR16 *TempSpot;
+ CHAR16 *SfoString;
ASSERT(FileName != NULL);
ASSERT(TableName != NULL);
@@ -299,8 +346,11 @@ PerformParsing( if (ColumnPointer != NULL && *ColumnPointer != CHAR_NULL && ColumnPointer[StrLen (ColumnPointer) - 1] == L'\"'){
ColumnPointer[StrLen (ColumnPointer) - 1] = CHAR_NULL;
}
-
- ShellPrintEx (-1, -1, L"%s\r\n", ColumnPointer);
+ SfoString = HandleStringWithEscapeCharForParse (ColumnPointer);
+ if (SfoString != NULL) {
+ ShellPrintEx (-1, -1, L"%s\r\n", SfoString);
+ SHELL_FREE_NON_NULL (SfoString);
+ }
}
}
}
|