[Fusionforge-commits] FusionForge branch master updated. ac47be133785d16a2f5b5ff4e43d59b49f7e98c1

Sylvain Beucler beuc-inria at fusionforge.org
Tue Sep 9 15:36:39 CEST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  ac47be133785d16a2f5b5ff4e43d59b49f7e98c1 (commit)
      from  b99191c037d4bd133321949e6e3ff06e156e4c2a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ac47be133785d16a2f5b5ff4e43d59b49f7e98c1
Author: Sylvain Beucler <sylvain.beucler at inria.fr>
Date:   Tue Sep 9 15:36:10 2014 +0200

    viewvc: properly handle headers

diff --git a/src/www/scm/include/viewvc_utils.php b/src/www/scm/include/viewvc_utils.php
index 85b3247..6ed3ac2 100644
--- a/src/www/scm/include/viewvc_utils.php
+++ b/src/www/scm/include/viewvc_utils.php
@@ -29,25 +29,6 @@
  * @version   $ID$
  */
 
-define ('SEPARATOR', "\n\t\r\0\x0B");
-
-/**
- *      viewcvs_is_html() - Test if ViewCVS returns HTML.
- *
- *      @return true if the content type of the ViewCVS is text/html.
- */
-function viewcvs_is_html() {
-	$request_uri = getStringFromServer('REQUEST_URI');
-	$query_string = getStringFromServer('QUERY_STRING');
-
-	return (strpos($request_uri,"*checkout*") === false &&
-		strpos($query_string,"view=graphimg") === false &&
-		strpos($query_string,"view=patch") === false &&
-		strpos($query_string,"view=tar") === false &&
-		strpos($request_uri,"*docroot*") === false &&
-		strpos($request_uri,"makepatch=1") === false);
-}
-
 /**
  * make_arg_cmd_safe() - Make strings safe for the command line.
  *
diff --git a/src/www/scm/viewvc.php b/src/www/scm/viewvc.php
index e708383..dd6b145 100644
--- a/src/www/scm/viewvc.php
+++ b/src/www/scm/viewvc.php
@@ -130,50 +130,36 @@ if ($external_scm) {
 	$content = viewcvs_execute($unix_name, $repos_type);
 }
 
-// TODO: filter output or adapt template to avoid CSS impact on <body>
-
 // Set content type header from the value set by ViewCVS
 // No other headers are generated by ViewCVS because in generate_etags
 // is set to 0 in the ViewCVS config file
 $found = false;
-$line = strtok($content,SEPARATOR);
-
-if ($line == 'Status: 301 Moved') {
-	while ($line) {
-		header($line);
-		$line = strtok(SEPARATOR);
+list($headers, $body) = explode("\r\n\r\n", $content);
+$headers = explode("\r\n", $headers);
+$content_type = '';
+$charset = '';
+foreach ($headers as $header) {
+	header($header);
+	if (preg_match('/^Content-Type:\s*(([^;]*)(\s*;\s*charset=(.*))?)/i', $header, $matches)) {
+		$content_type = $matches[2];
+		$charset = $matches[4];
 	}
-	exit;
 }
+//var_dump($content_type);
+//var_dump($charset);
 
-while ($line && !$found) {
-	if (preg_match('/^Content-Type:(.*)$/',$line,$matches)) {
-		header('Content-Type:' . $matches[1]);
-		$found = true;
-	}
-	$line = strtok(SEPARATOR);
-}
-$content = substr($content, strpos($content,$line));
-
-if (viewcvs_is_html()) {
+if (strpos($content_type, 'text/html') === 0) {
 	// If we output html and we found the mbstring extension, we
 	// should try to encode the output of ViewCVS in UTF-8
-	if (extension_loaded('mbstring')) {
-		$encoding = mb_detect_encoding($content, 'UTF-8, ISO-8859-1');
-		if($encoding != 'UTF-8') {
-			$content = mb_convert_encoding($content, 'UTF-8', $encoding);
-		}
-	}
+	if ($charset != 'UTF-8' && extension_loaded('mbstring'))
+		$content = mb_convert_encoding($content, 'UTF-8', $encoding);
 	scm_header(array('title'=>_("SCM Repository"),
 		'group'=>$Group->getID()));
 
-	echo $content;
+	echo $body;
 	scm_footer();
 } else {
-	// TODO does not seem to work when allow_tar = 1 in ViewCVS conf
-	// (allow to generate on the fly a tar.gz): the generated file
-	// seems to be corrupted
-	echo $content;
+	echo $body;
 }
 
 // Local Variables:
diff --git a/src/www/scm/viewvc/viewvc.cgi b/src/www/scm/viewvc/viewvc.cgi
index 2a944b7..18f151f 100755
--- a/src/www/scm/viewvc/viewvc.cgi
+++ b/src/www/scm/viewvc/viewvc.cgi
@@ -45,7 +45,8 @@ elif os.environ["REPOSITORY_TYPE"] == 'svn':
 
 cfg.general.address = "<a href='mailto:root@"+os.environ["HTTP_HOST"]+"'>root@" + os.environ["HTTP_HOST"]+ "</a>"
 cfg.options.docroot = os.environ["DOCROOT"]
-cfg.options.allow_compress = False
-cfg.options.generate_etags = False
+#cfg.options.allow_compress = False
+#cfg.options.generate_etags = False
+#cfg.options.allowed_views = ['annotate', 'diff', 'markup', 'roots', 'tar', 'co']
 
 viewvc.main(server, cfg)

-----------------------------------------------------------------------

Summary of changes:
 src/www/scm/include/viewvc_utils.php |   19 --------------
 src/www/scm/viewvc.php               |   46 ++++++++++++----------------------
 src/www/scm/viewvc/viewvc.cgi        |    5 ++--
 3 files changed, 19 insertions(+), 51 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list