CURLOPT_PATH_AS_IS.md (1748B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_PATH_AS_IS 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_DEBUGFUNCTION (3) 9 - CURLOPT_STDERR (3) 10 - CURLOPT_URL (3) 11 - curl_url_set (3) 12 Protocol: 13 - All 14 Added-in: 7.42.0 15 --- 16 17 # NAME 18 19 CURLOPT_PATH_AS_IS - do not handle dot-dot sequences 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PATH_AS_IS, long leaveit); 27 ~~~ 28 29 # DESCRIPTION 30 31 Set the long *leaveit* to 1, to explicitly tell libcurl to not alter the 32 given path before passing it on to the server. 33 34 This instructs libcurl to NOT squash sequences of "/../" or "/./" that may 35 exist in the URL's path part and that is supposed to be removed according to 36 RFC 3986 section 5.2.4. 37 38 Some server implementations are known to (erroneously) require the dot-dot 39 sequences to remain in the path and some clients want to pass these on in 40 order to try out server implementations. 41 42 By default libcurl normalizes such sequences before using the path. 43 44 This is a request for the *first* request libcurl issues. When following 45 redirects, it may no longer apply. 46 47 The corresponding flag for the curl_url_set(3) function is called 48 **CURLU_PATH_AS_IS**. 49 50 # DEFAULT 51 52 0 53 54 # %PROTOCOLS% 55 56 # EXAMPLE 57 58 ~~~c 59 int main(void) 60 { 61 CURL *curl = curl_easy_init(); 62 if(curl) { 63 curl_easy_setopt(curl, CURLOPT_URL, 64 "https://example.com/../../etc/password"); 65 66 curl_easy_setopt(curl, CURLOPT_PATH_AS_IS, 1L); 67 68 curl_easy_perform(curl); 69 } 70 } 71 ~~~ 72 73 # %AVAILABILITY% 74 75 # RETURN VALUE 76 77 curl_easy_setopt(3) returns a CURLcode indicating success or error. 78 79 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 80 libcurl-errors(3).