Fix lexer list parsing on Windows

When using a non-bundled Pygments (which is required on Windows, as the
bundled version is an ELF binary), we call into the Pygments executable
to generate the list of supported languages (lexers). This list seems to
occasionally include carraige returns, causing some languages to not be
processed correctly. Trim those CRs out so the language list is
accurate.

Bug: T336087
Change-Id: If8b1f145dd10e2c4707d6d32927e85d1d2459f15
(cherry picked from commit 2ae82c7fb7)
This commit is contained in:
Ryan Schmidt 2022-11-20 22:46:55 -07:00 committed by Reedy
parent 29d6f65f18
commit 57b3580811

View file

@ -56,7 +56,7 @@ class UpdateLexerList extends Maintenance {
$output = $result->getStdout();
foreach ( explode( "\n", $output ) as $line ) {
if ( substr( $line, 0, 1 ) === '*' ) {
$newLexers = explode( ', ', trim( $line, "* :\n" ) );
$newLexers = explode( ', ', trim( $line, "* :\r\n" ) );
// Skip internal, unnamed lexers
if ( $newLexers[0] !== '' ) {
$lexers = array_merge( $lexers, $newLexers );