Skip to content

Commit 31418ce

Browse files
author
unknown
committed
fixing file uploads on windows
1 parent d14dfaa commit 31418ce

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

PHPWebDriver/WebDriverBase.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,15 @@ protected function curl(http://github.com/$http_method,%3C/div%3E%3C/code%3E%3C/div%3E%3C/td%3E%3C/tr%3E%3Ctr%20class=%22diff-line-row%22%3E%3Ctd%20data-grid-cell-id=%22diff-0fbc28535908588d0e48a4b17fa7080b021a0e5c8b29e5a7a14e3d93cd622f6d-147-147-0%22%20data-selected=%22false%22%20role=%22gridcell%22%20style=%22background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">147
147
if ($http_method === 'POST') {
148148
curl_setopt($curl, CURLOPT_POST, true);
149149
if ($params && is_array($params)) {
150-
curl_setopt($curl, CURLOPT_POSTFIELDS, str_replace('\\\\u', '\\u', json_encode($params)));
150+
// hurray for magic strings!
151+
// due to how the remote server handles upload, they can stomp on special
152+
// unicode denoting characters in the json. so, unescape \uXXXX in the json
153+
// and then re-escape it if it is really \upload which is the prefix for temp
154+
// dir where files uploaded get stashed.
155+
$encoded_params = json_encode($params);
156+
$encoded_params = str_replace('\\\\u', '\\u', $encoded_params);
157+
$encoded_params = str_replace('\\upload', '\\\\upload', $encoded_params);
158+
curl_setopt($curl, CURLOPT_POSTFIELDS, $encoded_params);
151159
} else {
152160
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-length: 0'));
153161
}

0 commit comments

Comments
 (0)