21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

if (!isalnum(*input)) return 0;<br />

break;<br />

}<br />

}<br />

return (*input && !quoted_string);<br />

}<br />

static int spc_allow_tag(const char *input) {<br />

int i;<br />

char *tmp;<br />

if (*input == ’a’)<br />

return spc_is_valid_link(input + 1);<br />

if (*input == ’/’) {<br />

input++;<br />

SKIP_WHITESPACE(input);<br />

}<br />

for (i = 0; i < sizeof(allowed_formatters); i++) {<br />

if (strncasecmp(allowed_formatters[i], input, strlen(allowed_formatters[i])))<br />

continue;<br />

else {<br />

tmp = input + strlen(allowed_formatters[i]);<br />

SKIP_WHITESPACE(tmp);<br />

if (*input == ’>’) return 1;<br />

}<br />

}<br />

return 0;<br />

}<br />

/* Note: This interface expects a C-style NULL-terminated string. */<br />

char *spc_escape_html(const char *input) {<br />

char *output, *ptr;<br />

size_t outputlen = 0;<br />

const char *c;<br />

/* This is a worst-case length calculation */<br />

for (c = input; *c; c++) {<br />

switch (*c) {<br />

case ’’: outputlen += 4; break; /* &gt; */<br />

case ’&’: outputlen += 5; break; /* &amp; */<br />

case ’\’: outputlen += 6; break; /* &quot; */<br />

default: outputlen += 1; break;<br />

}<br />

}<br />

if (!(output = ptr = (char *)malloc(outputlen + 1))) return 0;<br />

for (c = input; *c; c++) {<br />

switch (*c) {<br />

case ’

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!