-const char encode_rcs[] = "$Id: encode.c,v 1.14 2008/05/21 15:38:13 fabiankeil Exp $";
+const char encode_rcs[] = "$Id: encode.c,v 1.19 2011/09/04 11:35:38 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/encode.c,v $
* Purpose : Functions to encode and decode URLs, and also to
* encode cookies and HTML text.
*
- * Copyright : Written by and Copyright (C) 2001 the SourceForge
+ * Copyright : Written by and Copyright (C) 2001 the
* Privoxy team. http://www.privoxy.org/
*
* Based on the Internet Junkbuster originally written
- * by and Copyright (C) 1997 Anonymous Coders and
+ * by and Copyright (C) 1997 Anonymous Coders and
* Junkbusters Corporation. http://www.junkbusters.com
*
- * This program is free software; you can redistribute it
+ * This program is free 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 2 of the License, or (at
"%FA", "%FB", "%FC", "%FD", "%FE", "%FF"
};
-/* Maps special characters in HTML to their equivalent entites. */
+/* Maps special characters in HTML to their equivalent entities. */
static const char * const html_code_map[256] = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,""",NULL,NULL,NULL,"&",NULL,
+ NULL, NULL, NULL, NULL,""",NULL,NULL,NULL,"&","'",
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
"<",NULL,">",NULL,NULL, NULL, NULL, NULL, NULL, NULL,
* Parameters :
* 1 : s = String to encode. Null-terminated.
*
- * Returns : Encoded string, newly allocated on the heap.
+ * Returns : Encoded string, newly allocated on the heap.
* Caller is responsible for freeing it with free().
* If s is NULL, or on out-of memory, returns NULL.
*
{
char * buf;
size_t buf_size;
-
+
if (s == NULL)
{
return NULL;
* Parameters :
* 1 : s = String to encode. Null-terminated.
*
- * Returns : Encoded string, newly allocated on the heap.
+ * Returns : Encoded string, newly allocated on the heap.
* Caller is responsible for freeing it with free().
* If s is NULL, or on out-of memory, returns NULL.
*
char * html_encode_and_free_original(char *s)
{
char * result;
-
+
if (s == NULL)
{
return NULL;
* Parameters :
* 1 : s = String to encode. Null-terminated.
*
- * Returns : Encoded string, newly allocated on the heap.
+ * Returns : Encoded string, newly allocated on the heap.
* Caller is responsible for freeing it with free().
* If s is NULL, or on out-of memory, returns NULL.
*
{
return(d - '0');
}
- else if ((d >= 'a') && (d <= 'f'))
+ else if ((d >= 'a') && (d <= 'f'))
{
return(d - 'a' + 10);
}
*********************************************************************/
int xtoi(const char *s)
{
- int d1, d2;
+ int d1;
d1 = xdtoi(*s);
if(d1 >= 0)
{
- d2 = xdtoi(*(s+1));
+ int d2 = xdtoi(*(s+1));
if(d2 >= 0)
{
return (d1 << 4) + d2;
* Parameters :
* 1 : s = String to decode. Null-terminated.
*
- * Returns : Decoded string, newly allocated on the heap.
+ * Returns : Decoded string, newly allocated on the heap.
* Caller is responsible for freeing it with free().
*
*********************************************************************/