lib543.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2021, 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. ***************************************************************************/
  22. /* Based on Alex Fishman's bug report on September 30, 2007 */
  23. #include "test.h"
  24. #include "memdebug.h"
  25. int test(char *URL)
  26. {
  27. static const unsigned char a[] = {
  28. 0x9c, 0x26, 0x4b, 0x3d, 0x49, 0x4, 0xa1, 0x1,
  29. 0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa,
  30. 0x1d, 0x57, 0xe1};
  31. CURL *easy;
  32. CURLcode res = CURLE_OK;
  33. (void)URL;
  34. global_init(CURL_GLOBAL_ALL);
  35. easy = curl_easy_init();
  36. if(!easy) {
  37. fprintf(stderr, "curl_easy_init() failed\n");
  38. res = TEST_ERR_MAJOR_BAD;
  39. }
  40. else {
  41. int asize = (int)sizeof(a);
  42. char *s = curl_easy_escape(easy, (const char *)a, asize);
  43. if(s) {
  44. printf("%s\n", s);
  45. curl_free(s);
  46. }
  47. s = curl_easy_escape(easy, "", 0);
  48. if(s) {
  49. printf("IN: '' OUT: '%s'\n", s);
  50. curl_free(s);
  51. }
  52. s = curl_easy_escape(easy, " 123", 3);
  53. if(s) {
  54. printf("IN: ' 12' OUT: '%s'\n", s);
  55. curl_free(s);
  56. }
  57. curl_easy_cleanup(easy);
  58. }
  59. curl_global_cleanup();
  60. return (int)res;
  61. }