diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-31 20:12:05 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-31 20:12:05 +0000 |
commit | 7da093a34832fd4766bb97e3161dfa478fd801f1 (patch) | |
tree | 8a142c9bcedae6f9932f8fdd1419a9f86f3bde77 /src | |
parent | 89738d69bbd119bc8b1625918c2f858c3e1007e4 (diff) |
Detect BRAINDEAD WINDOWS EDITORS THAT DEFAULT TO SAVING AS UTF-16! When we find out which editor did this, we'll use our retractable baton to teach it the true meaning of portable data.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7195 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/configreader.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index e05a78874..d7a456fdf 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -937,6 +937,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o bool in_tag; bool in_quote; bool in_comment; + int character_count = 0; linenumber = 1; in_tag = false; @@ -968,6 +969,21 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o /* Start reading characters... */ while(conf.get(ch)) { + + /* + * Fix for moronic windows issue spotted by Adremelech. + * Some windows editors save text files as utf-16, which is + * a total pain in the ass to parse. Users should save in the + * right config format! If we ever see a file where the first + * byte is 0xFF or 0xFE, or the second is 0xFF or 0xFE, then + * this is most likely a utf-16 file. Bail out and insult user. + */ + if ((character_count++ < 2) && (ch == '\xFF' || ch == '\xFE')) + { + errorstream << "File " << filename << " cannot be read, as it is encoded in braindead UTF-16. Save your file as plain ASCII!" << std::endl; + return false; + } + /* * Here we try and get individual tags on separate lines, * this would be so easy if we just made people format @@ -980,12 +996,6 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o if((ch == '#') && !in_quote) in_comment = true; - /*if(((ch == '\n') || (ch == '\r')) && in_quote) - { - errorstream << "Got a newline within a quoted section, this is probably a typo: " << filename << ":" << linenumber << std::endl; - return false; - }*/ - switch(ch) { case '\n': |