bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: image alttext quotes not escaped in info output


From: Karl Berry
Subject: Re: image alttext quotes not escaped in info output
Date: Sun, 8 Apr 2007 18:37:11 -0500

Hi Kevin,

Regarding escaping in alt strings for Info output, I made the following
change in makeinfo CVS.  I took the opportunity to also expand the text,
as is done for HTML.

If you can, please try it and let me know if problems.  I don't have any
easy way to really test it.

Thanks,
Karl


--- makeinfo.c.~1.94.~  2007-03-31 15:40:51.000000000 -0700
+++ makeinfo.c  2007-04-08 11:56:27.000000000 -0700
@@ -3315,4 +3316,27 @@
 }
 
+/* Replace " with \" and \ with \\.  Used for alt tag in Info output.
+   Return a newly-malloced string in all cases.  */
+
+static char *
+bs_escape_quote (const char *src)
+{
+  int c;
+  char *dest = xmalloc (2 * strlen (src) + 1);  /* can't need more.  */
+  char *p = dest;
+  
+  for (; c = *src; src++)
+    {
+      if (c == '"' || c == '\\')
+        *p++ = '\\';
+
+      *p++ = c;
+    }
+  *p = 0;
+  
+  return dest;
+}
+
+
 /* An external image is a reference, kind of.  The parsing is (not
    coincidentally) similar, anyway.  */
@@ -3480,5 +3504,11 @@
 
                   if (*alt_arg)
-                    add_word_args (" alt=\"%s\"", alt_arg);
+                    {
+                      char *expanded = text_expansion (alt_arg);
+                      char *escaped = bs_escape_quote (expanded);
+                      add_word_args (" alt=\"%s\"", escaped);
+                      free (expanded);
+                      free (escaped);
+                    }
                 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]