X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=libcitadel%2Flib%2Fhtml_to_ascii.c;h=6e4600ab19169317949538f7295e0404a4807268;hb=de0eab6118786f81de402fbef2f6d6ec116994aa;hp=b80272aecd0d7f8517801062fbcf8a1ac3b80cab;hpb=a347d141fd25064f6ecacf7e28dcbd7e6f2b295c;p=citadel.git diff --git a/libcitadel/lib/html_to_ascii.c b/libcitadel/lib/html_to_ascii.c index b80272aec..6e4600ab1 100644 --- a/libcitadel/lib/html_to_ascii.c +++ b/libcitadel/lib/html_to_ascii.c @@ -2,7 +2,7 @@ * Functions which handle translation between HTML and plain text * Copyright (c) 2000-2010 by the citadel.org team * - * This program is free software; you can redistribute it and/or modify + * This program is open source software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. @@ -469,9 +469,23 @@ char *html_to_ascii(const char *inputmsg, int msglen, int screenwidth, int do_ci strcpy(&outbuf[i+1], &outbuf[i+7]); } + else if (!strncasecmp(&outbuf[i], "’", 7)) { + outbuf[i] = '\''; + strcpy(&outbuf[i+1], &outbuf[i+7]); + } + + else if (!strncasecmp(&outbuf[i], "–", 7)) { + outbuf[i] = '-'; + strcpy(&outbuf[i+1], &outbuf[i+7]); + } + /* two-digit decimal equivalents */ - else if ((!strncmp(&outbuf[i], "&#", 2)) - && (outbuf[i+4] == ';') ) { + else if (outbuf[i] == '&' && + outbuf[i + 1] == '#' && + isdigit(outbuf[i + 2]) && + isdigit(outbuf[i + 3]) && + (outbuf[i+4] == ';') ) + { scanch = 0; sscanf(&outbuf[i+2], "%02d", &scanch); outbuf[i] = scanch; @@ -479,14 +493,34 @@ char *html_to_ascii(const char *inputmsg, int msglen, int screenwidth, int do_ci } /* three-digit decimal equivalents */ - else if ((!strncmp(&outbuf[i], "&#", 2)) - && (outbuf[i+5] == ';') ) { + else if (outbuf[i] == '&' && + outbuf[i + 1] == '#' && + isdigit(outbuf[i + 2]) && + isdigit(outbuf[i + 3]) && + isdigit(outbuf[i + 4]) && + (outbuf[i + 5] == ';') ) + { scanch = 0; sscanf(&outbuf[i+2], "%03d", &scanch); outbuf[i] = scanch; strcpy(&outbuf[i+1], &outbuf[i+6]); } + /* four-digit decimal equivalents */ + else if (outbuf[i] == '&' && + outbuf[i + 1] == '#' && + isdigit(outbuf[i + 2]) && + isdigit(outbuf[i + 3]) && + isdigit(outbuf[i + 4]) && + isdigit(outbuf[i + 5]) && + (outbuf[i + 6] == ';') ) + { + scanch = 0; + sscanf(&outbuf[i+2], "%04d", &scanch); + outbuf[i] = scanch; + strcpy(&outbuf[i+1], &outbuf[i+7]); + } + } /* Make sure the output buffer is big enough */