]> code.delx.au - refind/commitdiff
Changed quoting mechanism for quoting quote marks in configuration
authorsrs5694 <srs5694@users.sourceforge.net>
Thu, 6 Dec 2012 18:47:56 +0000 (13:47 -0500)
committersrs5694 <srs5694@users.sourceforge.net>
Thu, 6 Dec 2012 18:47:56 +0000 (13:47 -0500)
files.

NEWS.txt
docs/refind/configfile.html
docs/refind/linux.html
docs/refind/revisions.html
refind/config.c
refind/main.c

index 6f3e4666650f731ee7afe1d02f2c0df3075700df..1a4d5687746460b4b4ada1acdc553a3a53f34ac5 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,6 +1,13 @@
-0.5.0 (12/5/2012):
+0.5.0 (12/?/2012):
 ------------------
 
 ------------------
 
+- Added the ability to include quote marks ('"') in refind.conf and
+  refind_linux.conf tokens by doubling them up, as in:
+  "ro root=/dev/sda4 some_value=""this is it"""
+  This example results in the following string being passed as an
+  option:
+  ro root=/dev/sda4 some_value="this is it"
+
 - Changed refind.conf-sample to uncomment the scan_all_linux_kernels
   option by default. If this option is deleted or commented out, the
   program default remains to not scan all Linux kernels; but with
 - Changed refind.conf-sample to uncomment the scan_all_linux_kernels
   option by default. If this option is deleted or commented out, the
   program default remains to not scan all Linux kernels; but with
index ee0805b72f7a47dcf445e4546d4f6fd2cabce6cd..04c144e247e69a3be33b3553eb3d4b35197e0d5d 100644 (file)
@@ -305,7 +305,7 @@ default_selection elilo
 <tr>
    <td><tt>options</tt></td>
    <td>options passed to the boot loader</td>
 <tr>
    <td><tt>options</tt></td>
    <td>options passed to the boot loader</td>
-   <td>Pass arbitrary options to your boot loader with this line. Note that if the option string should contain spaces (as it often should) or characters that should not be modified by rEFInd's option parser (such as slashes or commas), it <i>must</i> be enclosed in quotes.</td>
+   <td>Pass arbitrary options to your boot loader with this line. Note that if the option string should contain spaces (as it often should) or characters that should not be modified by rEFInd's option parser (such as slashes or commas), it <i>must</i> be enclosed in quotes. If you must include quotes in an option, you can double them up, as in <tt>my_opt=""with quotes""</tt>, which passes <tt>my_opt="with quotes"</tt> as an option.</td>
 </tr>
 <tr>
    <td><tt>disabled</tt></td>
 </tr>
 <tr>
    <td><tt>disabled</tt></td>
index d702c0a3fa608ce81ad426a28054563fb3652ae7..011611ade78b80dc7779d151a33858696612d7c9 100644 (file)
@@ -186,7 +186,7 @@ total 17943
 # "Boot alternate install"   "root=/dev/sdb9 ro quiet splash vt.handoff=7"
 </pre>
 
 # "Boot alternate install"   "root=/dev/sdb9 ro quiet splash vt.handoff=7"
 </pre>
 
-<p>Ordinarily, both fields in this file must be enclosed in quotes. You can include as much white space as you like between options. You can also place comments in the file, or remove an option by commenting it out with a leading hash mark (<tt>#</tt>), as in the fourth line in this example.</p>
+<p>Ordinarily, both fields in this file must be enclosed in quotes. If you have to pass an option that includes quotes, you can do so by doubling up on them, as in <tt>"root=/dev/sdb9 my_opt=""this is it"""</tt>, which passes <tt>root=/dev/sdb9 my_opt="this is it"</tt> to the shell. You can include as much white space as you like between options. You can also place comments in the file, or remove an option by commenting it out with a leading hash mark (<tt>#</tt>), as in the fourth line in this example.</p>
 
 <p>In the preceding example, the first line sets the options that rEFInd passes to the kernel by default (along with the name of the <tt>initrd.img-3.3.0</tt> file, since its version string matches that of the kernel). The next two lines set options that you can obtain by pressing Insert, F2, or + on the main menu, as shown here:</p>
 
 
 <p>In the preceding example, the first line sets the options that rEFInd passes to the kernel by default (along with the name of the <tt>initrd.img-3.3.0</tt> file, since its version string matches that of the kernel). The next two lines set options that you can obtain by pressing Insert, F2, or + on the main menu, as shown here:</p>
 
index e0cbbbbeeb2f40a9f5f72af171a7ce62f0d552c6..a87c5dea3c032b0a7ee409acee268aefd5780b7b 100644 (file)
@@ -93,7 +93,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
 
 <ul>
 
 
 <ul>
 
-<li><b>0.5.0 (12/5/2012)</b>&mdash;I've focused on adding support for Matthew J. Garrett's shim program to this version of rEFInd; with this support, rEFInd is capable of launching Linux kernels and other programs signed with a suitable key while the computer is in Secure Boot mode. This initial release, however, requires significant manual configuration and has some known bugs and limitations. See the <a href="secureboot.html">Managing Secure Boot</a> page for details. Beyond this major new feature, this version includes several more minor improvements. These include a change to the <tt>resolution</tt> token so that it applies to text mode as well as to graphics mode; a bug fix that caused the line editor to blank out lines that were left unedited; a new <tt>dont_scan_files</tt> option to blacklist boot programs by filename; support for launching MokManager and Apple's Recovery HD partitions via tools (2nd-row) icons; new <tt>--usedefault</tt> and <tt>--drivers</tt> options to the <tt>install.sh</tt> script; and a change of the <tt>esp</tt> installation script option to <tt>--esp</tt>.</li>
+<li><b>0.5.0 (12/5/2012)</b>&mdash;I've focused on adding support for Matthew J. Garrett's shim program to this version of rEFInd; with this support, rEFInd is capable of launching Linux kernels and other programs signed with a suitable key while the computer is in Secure Boot mode. This initial release, however, requires significant manual configuration and has some known bugs and limitations. See the <a href="secureboot.html">Managing Secure Boot</a> page for details. Beyond this major new feature, this version includes several more minor improvements. These include a change to the <tt>resolution</tt> token so that it applies to text mode as well as to graphics mode; a bug fix that caused the line editor to blank out lines that were left unedited; a new <tt>dont_scan_files</tt> option to blacklist boot programs by filename; support for launching MokManager and Apple's Recovery HD partitions via tools (2nd-row) icons; new <tt>--usedefault</tt> and <tt>--drivers</tt> options to the <tt>install.sh</tt> script; a change of the <tt>esp</tt> installation script option to <tt>--esp</tt>; and the ability to use quote marks inside option strings by doubling them up.</li>
 
 <li><b>0.4.7 (11/6/2012)</b>&mdash;The most important new feature in this version is a boot options editor. From rEFInd's main menu, press Insert or F2 to see the options menu. Select one of the options and press Insert or F2 again and the screen switches to a text-mode display in which you can edit the options that will be passed to the boot loader. A second new feature is a new icon for <a href="http://freedesktop.org/wiki/Software/gummiboot">gummiboot,</a> which is another EFI boot manager. This version also alters the behavior of the <tt>scan_delay</tt> option, since I've been told that the previous version didn't work; the new one does. Finally, this version omits the space that followed boot options when booting most OSes. This behavior was inherited from rEFIt; a comment in the source code indicates it's needed by OS X, but I've been told it causes boot failures when launching Linux on some Macs. Thus, rEFInd now adds this space only when booting Mac OS X.</li>
 
 
 <li><b>0.4.7 (11/6/2012)</b>&mdash;The most important new feature in this version is a boot options editor. From rEFInd's main menu, press Insert or F2 to see the options menu. Select one of the options and press Insert or F2 again and the screen switches to a text-mode display in which you can edit the options that will be passed to the boot loader. A second new feature is a new icon for <a href="http://freedesktop.org/wiki/Software/gummiboot">gummiboot,</a> which is another EFI boot manager. This version also alters the behavior of the <tt>scan_delay</tt> option, since I've been told that the previous version didn't work; the new one does. Finally, this version omits the space that followed boot options when booting most OSes. This behavior was inherited from rEFIt; a comment in the source code indicates it's needed by OS X, but I've been told it causes boot failures when launching Linux on some Macs. Thus, rEFInd now adds this space only when booting Mac OS X.</li>
 
index d52ca9f800ca39d84ee038b8cb908dfc29daff63..e2750858308fc75d6cd2391d3d39c138ab316e88 100644 (file)
@@ -215,14 +215,47 @@ static CHAR16 *ReadLine(REFIT_FILE *File)
     return Line;
 }
 
     return Line;
 }
 
+// Returns FALSE if *p points to the end of a token, TRUE otherwise.
+// Also modifies *p **IF** the first and second characters are both
+// quotes ('"'); it deletes one of them.
+static BOOLEAN KeepReading(IN OUT CHAR16 *p, IN OUT BOOLEAN *IsQuoted) {
+   BOOLEAN MoreToRead = FALSE;
+   CHAR16  *Temp = NULL;
+//            while (*p && *p != '"' && ((*p != ' ' && *p != '\t' && *p != '=' && *p != '#' && *p != ',') || IsQuoted)) {
+
+   if ((p == NULL) || (IsQuoted == NULL))
+      return FALSE;
+
+   if (*p == L'\0')
+      return FALSE;
+
+   if ((*p != ' ' && *p != '\t' && *p != '=' && *p != '#' && *p != ',') || *IsQuoted) {
+      MoreToRead = TRUE;
+   }
+   if (*p == L'"') {
+      if (p[1] == L'"') {
+         Temp = StrDuplicate(&p[1]);
+         if (Temp != NULL) {
+            StrCpy(p, Temp);
+            FreePool(Temp);
+         }
+         MoreToRead = TRUE;
+      } else {
+         *IsQuoted = !(*IsQuoted);
+         MoreToRead = FALSE;
+      } // if/else second character is a quote
+   } // if first character is a quote
+
+   return MoreToRead;
+} // BOOLEAN KeepReading()
+
 //
 // get a line of tokens from a file
 //
 //
 // get a line of tokens from a file
 //
-
 UINTN ReadTokenLine(IN REFIT_FILE *File, OUT CHAR16 ***TokenList)
 {
     BOOLEAN         LineFinished, IsQuoted = FALSE;
 UINTN ReadTokenLine(IN REFIT_FILE *File, OUT CHAR16 ***TokenList)
 {
     BOOLEAN         LineFinished, IsQuoted = FALSE;
-    CHAR16          *Line, *Token, *p, *Temp;
+    CHAR16          *Line, *Token, *p;
     UINTN           TokenCount = 0;
 
     *TokenList = NULL;
     UINTN           TokenCount = 0;
 
     *TokenList = NULL;
@@ -235,7 +268,7 @@ UINTN ReadTokenLine(IN REFIT_FILE *File, OUT CHAR16 ***TokenList)
         p = Line;
         LineFinished = FALSE;
         while (!LineFinished) {
         p = Line;
         LineFinished = FALSE;
         while (!LineFinished) {
-            // skip whitespace
+            // skip whitespace & find start of token
             while ((*p == ' ' || *p == '\t' || *p == '=' || *p == ',') && !IsQuoted)
                 p++;
             if (*p == 0 || *p == '#')
             while ((*p == ' ' || *p == '\t' || *p == '=' || *p == ',') && !IsQuoted)
                 p++;
             if (*p == 0 || *p == '#')
@@ -248,18 +281,12 @@ UINTN ReadTokenLine(IN REFIT_FILE *File, OUT CHAR16 ***TokenList)
             Token = p;
 
             // find end of token
             Token = p;
 
             // find end of token
-            while (*p && *p != '"' && ((*p != ' ' && *p != '\t' && *p != '=' && *p != '#' && *p != ',') || IsQuoted)) {
-               if ((*p == '/') && !IsQuoted) // Switch Unix-style to DOS-style directory separators
-                  *p = '\\';
-               if (*p == '|') {
-                  Temp = StrDuplicate(&p[1]);
-                  StrCpy(p, Temp);
-               }
+            while (KeepReading(p, &IsQuoted)) {
+               if ((*p == L'/') && !IsQuoted) // Switch Unix-style to DOS-style directory separators
+                  *p = L'\\';
                p++;
                p++;
-            } // if
-            if (*p == '"')
-               IsQuoted = !IsQuoted;
-            if (*p == 0 || *p == '#')
+            } // while
+            if (*p == L'\0' || *p == L'#')
                 LineFinished = TRUE;
             *p++ = 0;
 
                 LineFinished = TRUE;
             *p++ = 0;
 
index ee9a36130a0350e7df2c08fd3a232c82d009423c..ec39e5accccf6424d846f869b1eacc466846903e 100644 (file)
@@ -118,7 +118,7 @@ static VOID AboutrEFInd(VOID)
 
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
 
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
-        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.7.11");
+        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.7.12");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");