/*
- * "$Id$"
+ * CGI template function.
*
- * CGI template function.
+ * Copyright 2007-2015 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cgiCopyTemplateFile() - Copy a template file and replace all the
- * '{variable}' strings with the variable value.
- * cgiCopyTemplateLang() - Copy a template file using a language...
- * cgiGetTemplateDir() - Get the templates directory...
- * cgiSetServerVersion() - Set the server name and CUPS version...
- * cgi_copy() - Copy the template file, substituting as needed...
- * cgi_puts() - Put a string to the output file, quoting as
- * needed...
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
*/
#include "cgi-private.h"
else if (s > name && ch == '?')
break;
else if (s < (name + sizeof(name) - 1))
- *s++ = ch;
+ *s++ = (char)ch;
*s = '\0';
*/
if (name[1])
- sprintf(outval, "%d", cgiGetSize(name + 1));
+ snprintf(outval, sizeof(outval), "%d", cgiGetSize(name + 1));
else
- sprintf(outval, "%d", element + 1);
+ snprintf(outval, sizeof(outval), "%d", element + 1);
outptr = outval;
}
* {name~refex?true:false} Regex match
*/
- op = ch;
+ op = (char)ch;
if (ch == '?')
{
continue;
else if (ch == '#')
{
- sprintf(s, "%d", element + 1);
+ snprintf(s, sizeof(compare) - (size_t)(s - compare), "%d", element + 1);
s += strlen(s);
}
else if (ch == '{')
innerptr = innername;
while ((ch = getc(in)) != EOF && ch != '}')
if (innerptr < (innername + sizeof(innername) - 1))
- *innerptr++ = ch;
+ *innerptr++ = (char)ch;
*innerptr = '\0';
if (innername[0] == '#')
- sprintf(s, "%d", cgiGetSize(innername + 1));
+ snprintf(s, sizeof(compare) - (size_t)(s - compare), "%d", cgiGetSize(innername + 1));
else if ((innerptr = strrchr(innername, '-')) != NULL &&
isdigit(innerptr[1] & 255))
{
if ((innerval = cgiGetArray(innername, atoi(innerptr) - 1)) == NULL)
*s = '\0';
else
- strlcpy(s, innerval, sizeof(compare) - (s - compare));
+ strlcpy(s, innerval, sizeof(compare) - (size_t)(s - compare));
}
else if (innername[0] == '?')
{
if ((innerval = cgiGetArray(innername + 1, element)) == NULL)
*s = '\0';
else
- strlcpy(s, innerval, sizeof(compare) - (s - compare));
+ strlcpy(s, innerval, sizeof(compare) - (size_t)(s - compare));
}
else if ((innerval = cgiGetArray(innername, element)) == NULL)
- snprintf(s, sizeof(compare) - (s - compare), "{%s}", innername);
+ snprintf(s, sizeof(compare) - (size_t)(s - compare), "{%s}", innername);
else
- strlcpy(s, innerval, sizeof(compare) - (s - compare));
+ strlcpy(s, innerval, sizeof(compare) - (size_t)(s - compare));
s += strlen(s);
}
else if (ch == '\\')
- *s++ = getc(in);
+ *s++ = (char)getc(in);
else
- *s++ = ch;
+ *s++ = (char)ch;
*s = '\0';
if (regcomp(&re, compare, REG_EXTENDED | REG_ICASE))
{
fprintf(stderr,
- "ERROR: Unable to compile regular expresion \"%s\"!\n",
+ "ERROR: Unable to compile regular expression \"%s\"!\n",
compare);
result = 0;
}
while (*s)
{
if (*s == '<')
- {
- /*
- * Pass <A HREF="url"> and </A>, otherwise quote it...
- */
-
- if (!_cups_strncasecmp(s, "<A HREF=\"", 9))
- {
- fputs("<A HREF=\"", out);
- s += 9;
-
- while (*s && *s != '\"')
- {
- if (*s == '&')
- fputs("&", out);
- else
- putc(*s, out);
-
- s ++;
- }
-
- if (*s)
- s ++;
-
- fputs("\">", out);
- }
- else if (!_cups_strncasecmp(s, "</A>", 4))
- {
- fputs("</A>", out);
- s += 3;
- }
- else
- fputs("<", out);
- }
+ fputs("<", out);
else if (*s == '>')
fputs(">", out);
else if (*s == '\"')
s ++;
}
}
-
-
-/*
- * End of "$Id$".
- */