诸暨麻将添加redis
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

88 行
2.3 KiB

  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2013, 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 http://curl.haxx.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. #include "curlcheck.h"
  23. #include "dotdot.h"
  24. #include "memdebug.h"
  25. static CURLcode unit_setup(void)
  26. {
  27. return CURLE_OK;
  28. }
  29. static void unit_stop(void)
  30. {
  31. }
  32. struct dotdot {
  33. const char *input;
  34. const char *output;
  35. };
  36. UNITTEST_START
  37. unsigned int i;
  38. int fails=0;
  39. struct dotdot pairs[] = {
  40. { "/a/b/c/./../../g", "/a/g" },
  41. { "mid/content=5/../6", "mid/6" },
  42. { "/hello/../moo", "/moo" },
  43. { "/1/../1", "/1" },
  44. { "/1/./1", "/1/1" },
  45. { "/1/..", "/" },
  46. { "/1/.", "/1/" },
  47. { "/1/./..", "/" },
  48. { "/1/./../2", "/2" },
  49. { "/hello/1/./../2", "/hello/2" },
  50. { "test/this", "test/this" },
  51. { "test/this/../now", "test/now" },
  52. { "/1../moo../foo", "/1../moo../foo"},
  53. { "/../../moo", "/moo"},
  54. { "/../../moo?andnot/../yay", "/moo?andnot/../yay"},
  55. { "/123?foo=/./&bar=/../", "/123?foo=/./&bar=/../"},
  56. { "/../moo/..?what", "/?what" },
  57. };
  58. for(i=0; i < sizeof(pairs)/sizeof(pairs[0]); i++) {
  59. char *out = Curl_dedotdotify((char *)pairs[i].input);
  60. if(strcmp(out, pairs[i].output)) {
  61. fprintf(stderr, "Test %d: '%s' gave '%s' instead of '%s'\n",
  62. i, pairs[i].input, out, pairs[i].output);
  63. fail("Test case output mismatched");
  64. fails++;
  65. }
  66. else
  67. fprintf(stderr, "Test %d: OK\n", i);
  68. free(out);
  69. }
  70. return fails;
  71. UNITTEST_STOP