mirror of https://github.com/moparisthebest/curl
1 - allow DICT with properly URL-escaped words, like using %20 for spaces
2 - properly escape certain letters within a DICT word to comply to the RFC2229
This commit is contained in:
parent
00312e95fe
commit
3c6d3b69c2
7
CHANGES
7
CHANGES
|
@ -6,6 +6,13 @@
|
||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
Daniel (10 May 2006)
|
||||||
|
- Fixed DICT in two aspects:
|
||||||
|
|
||||||
|
1 - allow properly URL-escaped words, like using %20 for spaces
|
||||||
|
|
||||||
|
2 - properly escape certain letters within a word to comply to the RFC2229
|
||||||
|
|
||||||
Daniel (9 May 2006)
|
Daniel (9 May 2006)
|
||||||
- Andreas Ntaflos reported a bug in libcurl.m4: When configuring my GNU
|
- Andreas Ntaflos reported a bug in libcurl.m4: When configuring my GNU
|
||||||
autotools project, which optionally (default=yes) uses libcurl on a system
|
autotools project, which optionally (default=yes) uses libcurl on a system
|
||||||
|
|
|
@ -20,6 +20,8 @@ This release includes the following changes:
|
||||||
|
|
||||||
This release includes the following bugfixes:
|
This release includes the following bugfixes:
|
||||||
|
|
||||||
|
o dict with letters such as space in a word
|
||||||
|
o dict with url-encoded words in the URL
|
||||||
o libcurl.m4 when default=yes but no libcurl was found
|
o libcurl.m4 when default=yes but no libcurl was found
|
||||||
o numerous bugs fixed in the TFTP code
|
o numerous bugs fixed in the TFTP code
|
||||||
o possible memory leak when adding easy handles to multi stack
|
o possible memory leak when adding easy handles to multi stack
|
||||||
|
|
55
lib/dict.c
55
lib/dict.c
|
@ -83,9 +83,46 @@
|
||||||
#define _MPRINTF_REPLACE /* use our functions only */
|
#define _MPRINTF_REPLACE /* use our functions only */
|
||||||
#include <curl/mprintf.h>
|
#include <curl/mprintf.h>
|
||||||
|
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#include "memdebug.h"
|
||||||
|
|
||||||
|
static char *unescape_word(struct SessionHandle *data, char *inp)
|
||||||
|
{
|
||||||
|
char *newp;
|
||||||
|
char *dictp;
|
||||||
|
char *ptr;
|
||||||
|
int len;
|
||||||
|
unsigned char byte;
|
||||||
|
int olen=0;
|
||||||
|
|
||||||
|
newp = curl_easy_unescape(data, inp, 0, &len);
|
||||||
|
if(!newp)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
dictp = malloc(len*2 + 1); /* add one for terminating zero */
|
||||||
|
if(dictp) {
|
||||||
|
/* According to RFC2229 section 2.2, these letters need to be escaped with
|
||||||
|
\[letter] */
|
||||||
|
for(ptr = newp;
|
||||||
|
(byte = (unsigned char)*ptr);
|
||||||
|
ptr++) {
|
||||||
|
if ((byte <= 32) || (byte == 127) ||
|
||||||
|
(byte == '\'') || (byte == '\"') || (byte == '\\')) {
|
||||||
|
dictp[olen++] = '\\';
|
||||||
|
}
|
||||||
|
dictp[olen++] = byte;
|
||||||
|
}
|
||||||
|
dictp[olen]=0;
|
||||||
|
|
||||||
|
free(newp);
|
||||||
|
}
|
||||||
|
return dictp;
|
||||||
|
}
|
||||||
|
|
||||||
CURLcode Curl_dict(struct connectdata *conn, bool *done)
|
CURLcode Curl_dict(struct connectdata *conn, bool *done)
|
||||||
{
|
{
|
||||||
char *word;
|
char *word;
|
||||||
|
char *eword;
|
||||||
char *ppath;
|
char *ppath;
|
||||||
char *database = NULL;
|
char *database = NULL;
|
||||||
char *strategy = NULL;
|
char *strategy = NULL;
|
||||||
|
@ -135,6 +172,10 @@ CURLcode Curl_dict(struct connectdata *conn, bool *done)
|
||||||
strategy = (char *)".";
|
strategy = (char *)".";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eword = unescape_word(data, word);
|
||||||
|
if(!eword)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
result = Curl_sendf(sockfd, conn,
|
result = Curl_sendf(sockfd, conn,
|
||||||
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
|
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
|
||||||
"MATCH "
|
"MATCH "
|
||||||
|
@ -145,8 +186,11 @@ CURLcode Curl_dict(struct connectdata *conn, bool *done)
|
||||||
|
|
||||||
database,
|
database,
|
||||||
strategy,
|
strategy,
|
||||||
word
|
eword
|
||||||
);
|
);
|
||||||
|
|
||||||
|
free(eword);
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
failf(data, "Failed sending DICT request");
|
failf(data, "Failed sending DICT request");
|
||||||
else
|
else
|
||||||
|
@ -179,6 +223,10 @@ CURLcode Curl_dict(struct connectdata *conn, bool *done)
|
||||||
database = (char *)"!";
|
database = (char *)"!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eword = unescape_word(data, word);
|
||||||
|
if(!eword)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
result = Curl_sendf(sockfd, conn,
|
result = Curl_sendf(sockfd, conn,
|
||||||
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
|
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
|
||||||
"DEFINE "
|
"DEFINE "
|
||||||
|
@ -186,7 +234,10 @@ CURLcode Curl_dict(struct connectdata *conn, bool *done)
|
||||||
"%s\r\n" /* word */
|
"%s\r\n" /* word */
|
||||||
"QUIT\r\n",
|
"QUIT\r\n",
|
||||||
database,
|
database,
|
||||||
word);
|
eword);
|
||||||
|
|
||||||
|
free(eword);
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
failf(data, "Failed sending DICT request");
|
failf(data, "Failed sending DICT request");
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue