MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cgiFormEncode

Function cgiFormEncode

cgi-bin/html.c:68–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66 */
67
68char * /* O - Destination string */
69cgiFormEncode(char *dst, /* I - Destination string */
70 const char *src, /* I - Source string */
71 size_t dstsize) /* I - Size of destination string */
72{
73 char *dstptr, /* Pointer into destination */
74 *dstend; /* End of destination */
75 static const char *hex = /* Hexadecimal characters */
76 "0123456789ABCDEF";
77
78
79 /*
80 * Mark the end of the string...
81 */
82
83 dstend = dst + dstsize - 1;
84
85 /*
86 * Loop through the source string and copy...
87 */
88
89 for (dstptr = dst; *src && dstptr < dstend;)
90 {
91 switch (*src)
92 {
93 case ' ' :
94 /*
95 * Encode spaces with a "+"...
96 */
97
98 *dstptr++ = '+';
99 src ++;
100 break;
101
102 case '&' :
103 case '%' :
104 case '+' :
105 /*
106 * Encode special characters with %XX escape...
107 */
108
109 if (dstptr < (dstend - 2))
110 {
111 *dstptr++ = '%';
112 *dstptr++ = hex[(*src & 255) >> 4];
113 *dstptr++ = hex[*src & 15];
114 src ++;
115 }
116 break;
117
118 default :
119 /*
120 * Copy other characters literally...
121 */
122
123 *dstptr++ = *src++;
124 break;
125 }

Callers 14

mainFunction · 0.85
cgiMoveJobsFunction · 0.85
cgiPrintCommandFunction · 0.85
cgiPrintTestPageFunction · 0.85
do_job_opFunction · 0.85
do_class_opFunction · 0.85
show_classFunction · 0.85
do_printer_opFunction · 0.85
show_printerFunction · 0.85
do_am_classFunction · 0.85
do_am_printerFunction · 0.85
do_set_allowed_usersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected