Last modified: 2010-05-15 15:28:21 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T2750, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 750 - config/index.php generates bad LocalSettings.php if uses CR/LF EOL.
config/index.php generates bad LocalSettings.php if uses CR/LF EOL.
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Installer (Other open bugs)
1.3.x
PC All
: Low normal with 2 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
http://meta.wikimedia.org/wiki/Wiki_o...
: patch
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-10-20 14:41 UTC by Zigger
Modified: 2010-05-15 15:28 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
HEAD patch for config/index.php (825 bytes, patch)
2005-06-22 14:51 UTC, Zigger
Details
REL1_4 patch for config/index.php (749 bytes, patch)
2005-06-22 14:51 UTC, Zigger
Details

Description Zigger 2004-10-20 14:41:59 UTC
If the MediaWiki distribution is unpacked with WinZip with the option "TAR file
smart CR/LF conversion" turned on (under Options|Configuration|Miscellaneous),
config/index.php is created with CR/LF EOLs.  Once configured, the created
LocalSettings.php has CR/CR/LF EOLs, which get further corrupted with subsequent
edits by Notepad or Wordpad.

One solution is to distribute the GZ file without the intermediary TAR file.

Another solution is to pre-process the LocalSettings.php text before writing it
to disk.
Comment 1 Rowan Collins [IMSoP] 2004-10-20 18:15:38 UTC
(In reply to comment #0)
> One solution is to distribute the GZ file without the intermediary TAR file.

A gzip (.gz) file is a compressed copy of exactly one file; there's no way of
gzipping multiple files to one target without first combining them into an
archive format, such as tar.
Comment 2 Zigger 2004-10-21 10:08:48 UTC
Thanks Rowan.  So how about compressing the distribution with something that
supports multiple files, & in config/index.php add  $local = strtr($local,
"\r\n", "\n")  or similar before writing LocalSettings.php ?
Comment 3 Zigger 2005-06-22 14:51:11 UTC
Created attachment 632 [details]
HEAD patch for config/index.php
Comment 4 Zigger 2005-06-22 14:51:55 UTC
Created attachment 633 [details]
REL1_4 patch for config/index.php
Comment 5 Brion Vibber 2005-06-22 20:13:01 UTC
What exactly is the source of this problem? Where do the extra characters come from? It presumably ought to 
work correctly if the files are CR/LF to begin with; where does it go wrong?
Comment 6 Zigger 2005-06-22 20:46:57 UTC
(In reply to comment #5)
> What exactly is the source of this problem? Where do the extra characters come
from? It presumably ought to 
> work correctly if the files are CR/LF to begin with; where does it go wrong?

This is what I think happens:
  config/index.php has CR/LF EOLs (thanks to a WinZip default for example).
  So writeLocalSettings() returns $local with CR/LF EOLs.
  $localsettings then adds lines at the start and end using $endl,
  which is also based on the config/index.php EOLs.
  The output file is fopen()'ed with a "t" mode, causing EOL translation
  from LF to CR/LF, so CR/LF becomes CR/CR/LF.
  Saving the LocalSettings.php from various editors then does more horrible EOL
stuff.

Using a mode of "b" would prevent the EOL translation, so LocalSettings.php
would get the same EOLs as config/index.php.  As administrators are likely to
edit LocalSettings.php, it seems like a good idea that this file has a native
EOL style instead of whatever default style the unpacking software happened to
use.  So the attached patches force LF-style EOLs after the output of
writeLocalSettings, allowing the "t" mode to do its thing.
Comment 7 Brion Vibber 2005-06-22 22:08:47 UTC
I applied a slightly modified patch; moved the two str_replaces into a single one in 
writeLocalSettings itself.

Applied on REL1_4 and HEAD.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links