[web-doc] master: this is even safer

From: Date: Wed, 19 May 2021 02:04:14 +0000
Subject: [web-doc] master: this is even safer
Groups: php.doc.web 
Request: Send a blank email to doc-web+get-2477@lists.php.net to get a copy of this message
Author: Nilgün Belma Bugüner (nilgun) Date: 2021-05-19T05:04:17+03:00 Commit: https://github.com/php/web-doc/commit/d77b6ea5a0b41f689abcbb09bbb54f5e0119a373 Raw diff: https://github.com/php/web-doc/commit/d77b6ea5a0b41f689abcbb09bbb54f5e0119a373.diff this is even safer Changed paths: M include/lib_revcheck.inc.php M www/revcheck.php Diff: diff --git a/include/lib_revcheck.inc.php b/include/lib_revcheck.inc.php index 4adc715..bdfbde1 100644 --- a/include/lib_revcheck.inc.php +++ b/include/lib_revcheck.inc.php @@ -238,32 +238,39 @@ function get_stats($idx, $lang, $status) { return array($result['total'], $result['size']); } -function showdiff ( $dir, $gitfile, $h2, $c ) +function showdiff () { - $cwd = getcwd(); - chdir( $dir ); - $file = git diff {$h2} -- {$gitfile}; - chdir( $cwd ); - $raw = htmlspecialchars( $file, ENT_XML1, 'UTF-8' ); - if ( $c == 'on' ) { - $trans = [ " " => "&nbsp;" ]; - $lines = explode ( "\n" , $raw ); - foreach ( $lines as $line ) { - $inline = strtr( $line , $trans ); - $fc = substr( $inline , 0 , 1 ); - if ( $fc == "+" ) { - echo "<div style='color:green;font-family:mono'>"; - } elseif ( $fc == "-" ) { - echo "<div style='color:red;font-family:mono'>"; - } elseif ( $fc == "@" ) { - echo "<div style='color:blue;font-family:mono'>"; - } else - echo "<div style='color:gray;font-family:mono'>"; - echo "$inline</div>\n"; - } - echo "<p></p>"; - } else - echo "<pre style='font-family:mono'>" , $raw , "</pre>"; + if (isset($_GET['f'])) { + $gitfile = $_GET['f']; + if (isset($_GET['hbp'])) + $h = $_GET['hbp']; + if (isset($_GET['c'])) + $c = $_GET['c']; + $cwd = getcwd(); + chdir( GIT_DIR . 'en' ); + $file = git diff {$h} -- {$gitfile}; + chdir( $cwd ); + $raw = htmlspecialchars( $file, ENT_XML1, 'UTF-8' ); + if ( $c == 'on' ) { + $trans = [ " " => "&nbsp;" ]; + $lines = explode ( "\n" , $raw ); + foreach ( $lines as $line ) { + $inline = strtr( $line , $trans ); + $fc = substr( $inline , 0 , 1 ); + if ( $fc == "+" ) { + echo "<div style='color:green;font-family:mono'>"; + } elseif ( $fc == "-" ) { + echo "<div style='color:red;font-family:mono'>"; + } elseif ( $fc == "@" ) { + echo "<div style='color:blue;font-family:mono'>"; + } else + echo "<div style='color:gray;font-family:mono'>"; + echo "$inline</div>\n"; + } + echo "<p></p>"; + } else + echo "<pre style='font-family:mono'>" , $raw , "</pre>"; + } } function gen_date($file) diff --git a/www/revcheck.php b/www/revcheck.php index ae4f60d..5551e90 100644 --- a/www/revcheck.php +++ b/www/revcheck.php @@ -382,14 +382,7 @@ break; case 'plain': - if (isset($_GET['f'])) { - $gitfile = $_GET['f']; - if (isset($_GET['hbp'])) - $h2 = $_GET['hbp']; - if (isset($_GET['c'])) - $c = $_GET['c']; - showdiff( GIT_DIR . 'en', $gitfile, $h2, $c ); - } + showdiff(); echo gen_date($DBLANG); break;

« previous php.doc.web (#2477) next »