2
0

lib543.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at https://curl.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. * SPDX-License-Identifier: curl
  22. *
  23. ***************************************************************************/
  24. /* Based on Alex Fishman's bug report on September 30, 2007 */
  25. #include "test.h"
  26. #include "memdebug.h"
  27. int test(char *URL)
  28. {
  29. static const unsigned char a[] = {
  30. 0x9c, 0x26, 0x4b, 0x3d, 0x49, 0x4, 0xa1, 0x1,
  31. 0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa,
  32. 0x1d, 0x57, 0xe1};
  33. CURL *easy;
  34. CURLcode res = CURLE_OK;
  35. (void)URL;
  36. global_init(CURL_GLOBAL_ALL);
  37. easy = curl_easy_init();
  38. if(!easy) {
  39. fprintf(stderr, "curl_easy_init() failed\n");
  40. res = TEST_ERR_MAJOR_BAD;
  41. }
  42. else {
  43. int asize = (int)sizeof(a);
  44. char *s = curl_easy_escape(easy, (const char *)a, asize);
  45. if(s) {
  46. printf("%s\n", s);
  47. curl_free(s);
  48. }
  49. s = curl_easy_escape(easy, "", 0);
  50. if(s) {
  51. printf("IN: '' OUT: '%s'\n", s);
  52. curl_free(s);
  53. }
  54. s = curl_easy_escape(easy, " 123", 3);
  55. if(s) {
  56. printf("IN: ' 12' OUT: '%s'\n", s);
  57. curl_free(s);
  58. }
  59. curl_easy_cleanup(easy);
  60. }
  61. curl_global_cleanup();
  62. return (int)res;
  63. }