From 51993faecb269024ed749d33a7b8de2d2c82a435 Mon Sep 17 00:00:00 2001 From: Tim Steiner <tsteiner2@unl.edu> Date: Tue, 7 Dec 2010 22:29:15 +0000 Subject: [PATCH] Merging changes for ticket 610 into production git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/production@365 20a16fea-79d4-4915-8869-1ea9d5ebf173 --- sites/all/modules/unl/unl_migration.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/sites/all/modules/unl/unl_migration.php b/sites/all/modules/unl/unl_migration.php index 5b2e9c07..0b8f41f8 100644 --- a/sites/all/modules/unl/unl_migration.php +++ b/sites/all/modules/unl/unl_migration.php @@ -457,6 +457,9 @@ class Unl_Migration_Tool return; } @drupal_mkdir('public://' . dirname($path), NULL, TRUE); + if (!mb_check_encoding($path, 'UTF-8')) { + $path = iconv('ISO-8859-1', 'UTF-8', $path); + } $file = file_save_data($data['content'], 'public://' . $path, FILE_EXISTS_REPLACE); $this->_hrefTransformFiles[$path] = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath() . '/' . $path; return; @@ -610,7 +613,7 @@ class Unl_Migration_Tool if (isset($parts['path'])) { while (strpos($parts['path'], '/./') !== FALSE) { - $parts['path'] = strtr($parts['path'], array('/./', '/')); + $parts['path'] = strtr($parts['path'], array('/./' => '/')); } $i = 0; while (strpos($parts['path'], '/../') !== FALSE) { @@ -698,6 +701,7 @@ class Unl_Migration_Tool curl_setopt($this->_curl, CURLOPT_URL, $url); curl_setopt($this->_curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($this->_curl, CURLOPT_HEADER, TRUE); + curl_setopt($this->_curl, CURLOPT_NOBODY, TRUE); $data = curl_exec($this->_curl); $meta = curl_getinfo($this->_curl); @@ -714,7 +718,17 @@ class Unl_Migration_Tool $headers[$headerKey] = trim($headerValue); } - $content = substr($data, $meta['header_size']); + // don't copy files greater than 100MB in size + if (isset($headers['Content-Length']) && $headers['Content-Length'] > (100 * 1024 * 1024)) { + $size = floor($headers['Content-Length'] / (1024 * 1024)); + $this->_log("The file at $url is $size MB! Ignoring."); + $content = ''; + } else { + curl_setopt($this->_curl, CURLOPT_NOBODY, FALSE); + $data = curl_exec($this->_curl); + $content = substr($data, $meta['header_size']); + } + if (in_array($meta['http_code'], array(301, 302))) { $location = $headers['Location']; -- GitLab