| 113 | } |
| 114 | |
| 115 | int acl_html_decode(const char *in, ACL_VSTRING *out) |
| 116 | { |
| 117 | int n = 0, len; |
| 118 | const char *ptr = in, *pre; |
| 119 | const ACL_TOKEN *token; |
| 120 | const HTML_SPEC *spec; |
| 121 | |
| 122 | acl_pthread_once(&__decode_token_once, html_decode_init); |
| 123 | if (__decode_token_tree == NULL) |
| 124 | acl_msg_fatal("__decode_token_tree null"); |
| 125 | |
| 126 | while (*ptr != 0) { |
| 127 | pre = ptr; |
| 128 | token = acl_token_tree_match(__decode_token_tree, |
| 129 | &ptr, NULL, NULL); |
| 130 | if (token == NULL) { |
| 131 | pre = markup_unescape(pre, out); |
| 132 | len = (int) (ptr - pre); |
| 133 | if (len > 0) |
| 134 | acl_vstring_memcat(out, pre, len); |
| 135 | break; |
| 136 | } |
| 137 | spec = (const HTML_SPEC*) token->ctx; |
| 138 | acl_assert(spec != NULL); |
| 139 | |
| 140 | len = (int) (ptr - pre - spec->len); |
| 141 | if (len > 0) |
| 142 | acl_vstring_memcat(out, pre, len); |
| 143 | if (spec->ch > 255) |
| 144 | acl_vstring_memcat(out, (char*) &spec->ch, sizeof(spec->ch)); |
| 145 | else |
| 146 | ACL_VSTRING_ADDCH(out, (unsigned char) spec->ch); |
| 147 | n++; |
| 148 | } |
| 149 | |
| 150 | ACL_VSTRING_TERMINATE(out); |
| 151 | return (n); |
| 152 | } |
| 153 | |
| 154 | #endif /* ACL_CLIENT_ONLY */ |
no test coverage detected
searching dependent graphs…