diff --git a/README.md b/README.md index 6ef19fb0..1cd07a41 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ ## Changelog +### 1.7.0 + + * Adds normalization of file upload name (https://github.com/Reposoft/rweb/pull/14) + * Drops support for svn <1.5 + * Adds support for a REPOS_TEMP variable to specify tmp dir + - Performance of the backing volume matters in edit operations due to temporary WCs + ### 1.6.0 * Recommends PHP 7 diff --git a/build.sh b/build.sh index 13c43ab1..b29a68e4 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,5 @@ #!/bin/bash -VERSION=1.6.2 +VERSION=1.7.0 rm -Rf target mkdir target cp -r repos-plugins target/ diff --git a/docker-compose.yml b/docker-compose.yml index 76167457..fada42a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,12 @@ -# For development at http://svn/, assuming local scripts build and libs install +# For development at http://svn/, assuming local scripts build and libs install, and hosts file record for svn +# Image builds see https://github.com/Reposoft/docker-svn # Create repo: docker-compose exec svn repocreate test -o daemon # Install libs: http://svn/repos-web/lib/smarty/install.php +# or: docker-compose exec rweb php /opt/rweb/repos-web/lib/smarty/install.php version: '2.1' services: svn: - image: solsson/rweb-httpd@sha256:f69fc496a781e6cdcd8156e6a2c14b33377ef6b2b8538cdc6b570e47cb89adc8 + image: solsson/rweb-httpd@sha256:4a0661e12da2ef4cc5dfbff08213a28b628bd522c85607e26e3425e30310821b expose: - "80" ports: @@ -15,7 +17,7 @@ services: volumes: - .:/opt/rweb rweb: - image: solsson/rweb@sha256:4531be10995942642442a4efa73762dd9e11828a8457a98c2a15f673fbfa93d4 + image: solsson/rweb@sha256:9690296ec8c59cef6a65e7a5bdb7fe77bbd8edc5cdd07b3bccc294c2cb6f02e2 expose: - "9000" links: diff --git a/package.json b/package.json index b4b46805..5defbaf8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rweb", - "version": "1.6.0", + "version": "1.7.0", "description": "Repos Web REST API and simple UI for version control", "author": "Repos Mjukvara AB", "license": "CC-BY-NC-4.0", diff --git a/repos-web/conf/System.class.php b/repos-web/conf/System.class.php index 082d9d77..c73b4567 100644 --- a/repos-web/conf/System.class.php +++ b/repos-web/conf/System.class.php @@ -484,7 +484,10 @@ function _getSystemTemp() { static $tempfolder = null; if (!is_null($tempfolder)) return $tempfolder; $type = ''; - if (getenv('TMP')) { + if (getenv('REPOS_TEMP')) { + $type = 'REPOS_TEMP'; + $tempdir = getenv('REPOS_TEMP'); + } elseif (getenv('TMP')) { $type = 'TMP'; $tempdir = getenv('TMP'); } elseif (getenv('TMPDIR')) { @@ -501,7 +504,7 @@ function _getSystemTemp() { $type = 'tempnam'; // suggest a directory that does not exist, so that tempnam uses system temp dir $doesnotexist = 'dontexist'.rand(); - $tmpfile = tempnam($doesnotexist, 'emptytempfile'); + $tmpfile = @tempnam($doesnotexist, 'emptytempfile'); if (strpos($tmpfile, $doesnotexist)!==false) trigger_error("Could not get system temp, got: ".$tmpfile, E_USER_ERROR); if (!file_exists($tmpfile)) trigger_error("Failed to create temp file using $type", E_USER_ERROR); $tempdir = dirname($tmpfile); diff --git a/repos-web/conf/repos.properties.php b/repos-web/conf/repos.properties.php index 0045bd06..b3eb5669 100644 --- a/repos-web/conf/repos.properties.php +++ b/repos-web/conf/repos.properties.php @@ -17,7 +17,7 @@ * @see Presentation * @package conf */ -define('REPOS_VERSION','1.6'); +define('REPOS_VERSION','1.7'); // ----- global settings ----- @@ -625,6 +625,32 @@ function xmlEncodePath($path) { return str_replace('&', '&', $path); } +/** + * Runs unicode normalization on request parameters. + * + * For example to help avoid https://issues.apache.org/jira/browse/SVN-2464 + * reposNormalizeParams($_POST, ['name']); + */ +function reposNormalizeParams(&$hash, $params) { + if (isset($_SERVER['REPOS_NORMALIZE']) && $_SERVER['REPOS_NORMALIZE']=='off') { + return; + } + if (!is_array($hash)) { + error_log("reposNormalizeParams called with a non-hash"); + return; + } + if (!class_exists('Normalizer')) { + error_log("Normalize class not found. Is the intl extension enabled?"); + return; + } + foreach ($params as $param) { + if (array_key_exists($param, $hash) && !Normalizer::isNormalized($hash[$param])) { + error_log("Param '$param' needs unicode normalization from: $hash[$param]"); + $hash[$param] = Normalizer::normalize($hash[$param]); + } + } +} + // ----- internal functions ----- function _getStackTrace() { diff --git a/repos-web/edit/delete/index.php b/repos-web/edit/delete/index.php index 864a2ec6..85262eee 100644 --- a/repos-web/edit/delete/index.php +++ b/repos-web/edit/delete/index.php @@ -28,6 +28,7 @@ function delete($message) { $edit->addArgUrl(getTargetUrl()); $edit->addArgRevpropsFromPost(); $edit->exec(); - displayEdit(Presentation::background(), dirname(rtrim(getTargetUrl(),'/')), false); + $template = Presentation::background(); + displayEdit($template, dirname(rtrim(getTargetUrl(),'/')), false); } ?> \ No newline at end of file diff --git a/repos-web/edit/upload/index.php b/repos-web/edit/upload/index.php index d586fd33..ce0270f9 100755 --- a/repos-web/edit/upload/index.php +++ b/repos-web/edit/upload/index.php @@ -44,7 +44,9 @@ // it might not automatically send credentials for this path targetLogin(); } - + + reposNormalizeParams($_POST, ['name']); + $folderRule = new ResourceExistsRule('target'); new NewFilenameRule("name", $folderRule->getValue()); @@ -125,19 +127,7 @@ function processFile($upload) { $sparse->addArgPath($dir . $filename); if ($sparse->execNoDisplay()) trigger_error('Failed to get target file from repository.', E_USER_ERROR); } else { - // warn because this operation may have serious performance impact - error_log('svn depth=empty checkout for file upload failed -- temp working copy will contain all folder immediates'); - // fallback: svn 1.4 and older - $checkout = new SvnEdit('checkout'); - $checkout->addArgOption('--non-recursive'); - if ($fromrev) $checkout->addArgOption('-r', $fromrev, false); - $checkout->addArgUrl($repoFolder); - $checkout->addArgPath($dir); - $checkout->exec(); - if (!$checkout->isSuccessful()) { - $presentation->showError("Could not read current version of file " - .$upload->getTargetUrl().". ".$checkout->getResult()); - } + trigger_error('Failed to create working copy', E_USER_ERROR); } // for PHP operations like file_exist below, we need to use an encoded path on windows // while the subversion commands use $dir.$filename and the setlocale in Command class diff --git a/repos-web/index_en.html b/repos-web/index_en.html index 72883e78..b3e3f4fa 100644 --- a/repos-web/index_en.html +++ b/repos-web/index_en.html @@ -67,7 +67,7 @@

Server settings

diff --git a/repos-web/version/index.php b/repos-web/version/index.php index 40125e9b..ca42d66f 100644 --- a/repos-web/version/index.php +++ b/repos-web/version/index.php @@ -8,7 +8,7 @@ $v = array(); # tag replaced by build script -$v['releaseversion'] = '1.6'; +$v['releaseversion'] = '1.7'; # info from svn if the application is checked out $v['system'] = array(); diff --git a/repos-web/view/repos.xsl b/repos-web/view/repos.xsl index 9d3ed655..3a061707 100644 --- a/repos-web/view/repos.xsl +++ b/repos-web/view/repos.xsl @@ -177,7 +177,7 @@