Skip to content

Commit

Permalink
Merge de616af into 02eb618
Browse files Browse the repository at this point in the history
  • Loading branch information
bagder committed Sep 10, 2017
2 parents 02eb618 + de616af commit dd1ff2f
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 21 deletions.
1 change: 1 addition & 0 deletions .travis-iconv-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export CPPFLAGS="-DCURL_DOES_CONVERSIONS -DHAVE_ICONV -DCURL_ICONV_CODESET_OF_HOST='\"ISO8859-1\"'"
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ matrix:
compiler: clang
dist: trusty
env: T=debug
- os: linux
compiler: gcc
dist: trusty
env: T=iconv
- os: osx
compiler: gcc
env: T=debug
Expand Down Expand Up @@ -115,6 +119,13 @@ script:
make && make examples
make test-nonflaky
fi
- |
if [ "$T" = "iconv" ]; then
source .travis-iconv-env.sh
./configure --enable-debug --enable-werror $C
make && make examples
make TFLAGS=-n test-nonflaky
fi
- |
if [ "$T" = "cmake" ]; then
mkdir build
Expand Down
6 changes: 3 additions & 3 deletions lib/escape.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
Expand Down Expand Up @@ -116,7 +116,7 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
ns = testing_ptr;
}

result = Curl_convert_to_network(data, &in, 1);
result = Curl_convert_to_network(data, (char *)&in, 1);
if(result) {
/* Curl_convert_to_network calls failf if unsuccessful */
free(ns);
Expand Down Expand Up @@ -173,7 +173,7 @@ CURLcode Curl_urldecode(struct Curl_easy *data,

in = curlx_ultouc(hex); /* this long is never bigger than 255 anyway */

result = Curl_convert_from_network(data, &in, 1);
result = Curl_convert_from_network(data, (char *)&in, 1);
if(result) {
/* Curl_convert_from_network calls failf if unsuccessful */
free(ns);
Expand Down
6 changes: 3 additions & 3 deletions lib/non-ascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ CURLcode Curl_convert_to_network(struct Curl_easy *data,
/* call iconv */
input_ptr = output_ptr = buffer;
in_bytes = out_bytes = length;
rc = iconv(*cd, (const char **)&input_ptr, &in_bytes,
rc = iconv(*cd, &input_ptr, &in_bytes,
&output_ptr, &out_bytes);
if(!data)
iconv_close(tmpcd);
Expand Down Expand Up @@ -182,7 +182,7 @@ CURLcode Curl_convert_from_network(struct Curl_easy *data,
/* call iconv */
input_ptr = output_ptr = buffer;
in_bytes = out_bytes = length;
rc = iconv(*cd, (const char **)&input_ptr, &in_bytes,
rc = iconv(*cd, &input_ptr, &in_bytes,
&output_ptr, &out_bytes);
if(!data)
iconv_close(tmpcd);
Expand Down Expand Up @@ -224,7 +224,7 @@ CURLcode Curl_convert_from_utf8(struct Curl_easy *data,
/* do the translation ourselves */
iconv_t tmpcd = (iconv_t) -1;
iconv_t *cd = &tmpcd;
const char *input_ptr;
char *input_ptr;
char *output_ptr;
size_t in_bytes, out_bytes, rc;

Expand Down
26 changes: 13 additions & 13 deletions lib/transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,20 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
strlen(endofline_network));

#ifdef CURL_DOES_CONVERSIONS
CURLcode result;
int length;
if(data->set.prefer_ascii) {
/* translate the protocol and data */
length = nread;
}
else {
/* just translate the protocol portion */
length = strlen(hexbuffer);
{
CURLcode result;
int length;
if(data->set.prefer_ascii)
/* translate the protocol and data */
length = nread;
else
/* just translate the protocol portion */
length = strlen(hexbuffer);
result = Curl_convert_to_network(data, data->req.upload_fromhere, length);
/* Curl_convert_to_network calls failf if unsuccessful */
if(result)
return result;
}
result = Curl_convert_to_network(data, data->req.upload_fromhere, length);
/* Curl_convert_to_network calls failf if unsuccessful */
if(result)
return result;
#endif /* CURL_DOES_CONVERSIONS */

if((nread - hexlen) == 0)
Expand Down
32 changes: 30 additions & 2 deletions tests/server/getpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
Expand Down Expand Up @@ -66,6 +66,35 @@ curl_wcsdup_callback Curl_cwcsdup = (curl_wcsdup_callback)_wcsdup;
# pragma warning(default:4232) /* MSVC extension, dllimport identity */
#endif


/*
* Curl_convert_clone() returns a malloced copy of the source string (if
* returning CURLE_OK), with the data converted to network format. This
* function is used by base64 code in libcurl built to support data
* conversion. This is a DUMMY VERSION that returns data unmodified - for
* use by the test server only.
*/
CURLcode Curl_convert_clone(struct Curl_easy *data,
const char *indata,
size_t insize,
char **outbuf);
CURLcode Curl_convert_clone(struct Curl_easy *data,
const char *indata,
size_t insize,
char **outbuf)
{
char *convbuf;
(void)data;

convbuf = malloc(insize);
if(!convbuf)
return CURLE_OUT_OF_MEMORY;

memcpy(convbuf, indata, insize);
*outbuf = convbuf;
return CURLE_OK;
}

/*
* readline()
*
Expand Down Expand Up @@ -451,4 +480,3 @@ int getpart(char **outbuf, size_t *outlen,

return error;
}

0 comments on commit dd1ff2f

Please sign in to comment.