Index: branches/new-upload/phase3/skins/common/upload.js |
— | — | @@ -87,8 +87,7 @@ |
88 | 88 | var obj = this; |
89 | 89 | var fileName = this.nameToCheck; |
90 | 90 | sajax_do_call( 'UploadForm::ajaxGetExistsWarning', [this.nameToCheck], |
91 | | - function (result) { |
92 | | - |
| 91 | + function (result) { |
93 | 92 | obj.processResult(result, fileName) |
94 | 93 | } |
95 | 94 | ); |
— | — | @@ -148,7 +147,9 @@ |
149 | 148 | fname = path.substring(backslash+1, 10000); |
150 | 149 | } |
151 | 150 | //check for the wgFileExtensions and clear if not a valid fname extension |
152 | | - if( wgFileExtensions ){ |
| 151 | + |
| 152 | + //urls are less likely to have a usefull extension don't include them in the extention check |
| 153 | + if( wgFileExtensions && id != 'wpUploadFileURL' ){ |
153 | 154 | var found = false; |
154 | 155 | if( fname.lastIndexOf('.')!=-1 ){ |
155 | 156 | var ext = fname.substr( fname.lastIndexOf('.')+1 ); |
Index: branches/new-upload/phase3/includes/HttpFunctions.php |
— | — | @@ -31,10 +31,16 @@ |
32 | 32 | global $wgPhpCliPath, $wgMaxUploadSize; |
33 | 33 | //do a quick check to HEAD to insure the file size is not > $wgMaxUploadSize to large no need to download it |
34 | 34 | $head = get_headers($url, 1); |
35 | | - if($head['Content-Length'] > $wgMaxUploadSize){ |
36 | | - return Status::newFatal('requested file length ' . $head['Content-Length'] . ' is greater than $wgMaxUploadSize: ' . $wgMaxUploadSize); |
37 | | - } |
| 35 | + |
| 36 | + //check for redirects: |
| 37 | + |
38 | 38 | $content_length = (isset($head['Content-Length']))?$head['Content-Length']:null; |
| 39 | + if($content_length){ |
| 40 | + if($content_length > $wgMaxUploadSize){ |
| 41 | + return Status::newFatal('requested file length ' . $content_length . ' is greater than $wgMaxUploadSize: ' . $wgMaxUploadSize); |
| 42 | + } |
| 43 | + } |
| 44 | + |
39 | 45 | //check if we can find phpCliPath (for doing a background shell request to php to do the download: |
40 | 46 | if( $wgPhpCliPath && wfShellExecEnabled() && $dl_mode == self::ASYNC_DOWNLOAD){ |
41 | 47 | wfDebug("\ASYNC_DOWNLOAD\n"); |
— | — | @@ -100,6 +106,7 @@ |
101 | 107 | */ |
102 | 108 | public static function doSessionIdDownload( $session_id, $upload_session_key ){ |
103 | 109 | global $wgUser, $wgEnableWriteAPI; |
| 110 | + wfDebug("\n\ndoSessionIdDownload\n\n"); |
104 | 111 | //set session to the provided key: |
105 | 112 | session_id($session_id); |
106 | 113 | //start the session |
— | — | @@ -124,23 +131,26 @@ |
125 | 132 | 'upload_session_key' => $upload_session_key |
126 | 133 | ) ); |
127 | 134 | //run the actual request .. (this can take some time) |
128 | | - wfDebug("doRequest: " . $sd['url'] . ' tf: ' . $sd['target_file_path'] ); |
129 | | - $status = $req->doRequest(); |
| 135 | + wfDebug("do Request: " . $sd['url'] . ' tf: ' . $sd['target_file_path'] ); |
| 136 | + $status = $req->doRequest(); |
| 137 | + wfDebug("done with req status is: ". $status->isOK(). ' '.$status->value. "\n"); |
130 | 138 | |
131 | | - |
132 | | - //start up the session again: |
133 | | - if( session_start() === false){ |
134 | | - wfDebug( __METHOD__ . ' ERROR:: Could not start session'); |
135 | | - } |
136 | | - //re-grab the updated session data: |
137 | | - $sd =& $_SESSION[ 'wsDownload' ][$upload_session_key]; |
138 | | - if( $status->isOK() ){ |
| 139 | + if( $status->isOK() ){ |
| 140 | + |
| 141 | + //start up the session again: |
| 142 | + if( session_start() === false){ |
| 143 | + wfDebug( __METHOD__ . ' ERROR:: Could not start session'); |
| 144 | + } |
| 145 | + //re-grab the updated session data: |
| 146 | + $sd =& $_SESSION[ 'wsDownload' ][$upload_session_key]; |
| 147 | + |
139 | 148 | //setup the faxRequest |
140 | 149 | $fauxReqData = $sd['mParams']; |
141 | 150 | $fauxReqData['action'] = 'upload'; |
142 | 151 | $fauxReqData['format'] = 'json'; |
143 | 152 | $fauxReqData['internalhttpsession'] = $upload_session_key; |
144 | | - |
| 153 | + //evil but no other clean way about it: |
| 154 | + |
145 | 155 | $faxReq = new FauxRequest($fauxReqData, true); |
146 | 156 | $processor = new ApiMain($faxReq, $wgEnableWriteAPI); |
147 | 157 | |
— | — | @@ -151,15 +161,15 @@ |
152 | 162 | $printer->initPrinter(false); |
153 | 163 | ob_start(); |
154 | 164 | $printer->execute(); |
155 | | - $apiUploadResult = ob_get_clean(); |
156 | | - |
| 165 | + $apiUploadResult = ob_get_clean(); |
| 166 | + |
| 167 | + wfDebug("\n\n got:" . $apiUploadResult." \n"); |
| 168 | + |
| 169 | + wfDebug("\n\n got api result:: $apiUploadResult \n" ); |
157 | 170 | //the status updates runner will grab the result form the session: |
158 | | - $sd['apiUploadResult'] = $apiUploadResult; |
159 | | - }else{ |
160 | | - //status != OK |
161 | | - $sd['apiUploadResult'] = ApiFormatJson::getJsonEncode( array( 'error' => $status->getWikiText() ) ); |
| 171 | + $sd['apiUploadResult'] = $apiUploadResult; |
| 172 | + session_write_close(); |
162 | 173 | } |
163 | | - session_write_close(); |
164 | 174 | } |
165 | 175 | |
166 | 176 | /** |
— | — | @@ -230,7 +240,7 @@ |
231 | 241 | } |
232 | 242 | } |
233 | 243 | private function doCurlReq(){ |
234 | | - global $wgHTTPFileTimeout, $wgHTTPTimeout, $wgHTTPProxy, $wgTitle; |
| 244 | + global $wgHTTPFileTimeout, $wgHTTPProxy, $wgTitle; |
235 | 245 | |
236 | 246 | $status = Status::newGood(); |
237 | 247 | $c = curl_init( $this->url ); |
— | — | @@ -240,8 +250,11 @@ |
241 | 251 | curl_setopt( $c, CURLOPT_PROXY, 'localhost:80' ); |
242 | 252 | } else if ($wgHTTPProxy) { |
243 | 253 | curl_setopt($c, CURLOPT_PROXY, $wgHTTPProxy); |
244 | | - } |
| 254 | + } |
245 | 255 | |
| 256 | + curl_setopt( $c, CURLOPT_TIMEOUT, $wgHTTPFileTimeout ); |
| 257 | + |
| 258 | + |
246 | 259 | curl_setopt( $c, CURLOPT_USERAGENT, Http::userAgent() ); |
247 | 260 | |
248 | 261 | if ( $this->method == 'POST' ) { |
— | — | @@ -268,11 +281,6 @@ |
269 | 282 | $status = $cwrite->status; |
270 | 283 | } |
271 | 284 | curl_setopt( $c, CURLOPT_WRITEFUNCTION, array($cwrite, 'callbackWriteBody') ); |
272 | | - //set to the file time out: |
273 | | - curl_setopt( $c, CURLOPT_TIMEOUT, $wgHTTPFileTimeout ); |
274 | | - }else{ |
275 | | - //set to script time timeout |
276 | | - curl_setopt( $c, CURLOPT_TIMEOUT, $wgHTTPTimeout ); |
277 | 285 | } |
278 | 286 | |
279 | 287 | //start output grabber: |
— | — | @@ -307,7 +315,6 @@ |
308 | 316 | if ( $retcode != 200 ) { |
309 | 317 | wfDebug( __METHOD__ . ": HTTP return code $retcode\n" ); |
310 | 318 | $status = Status::newFatal( "HTTP return code $retcode\n" ); |
311 | | - |
312 | 319 | } |
313 | 320 | # Don't return truncated output |
314 | 321 | $errno = curl_errno( $c ); |