Forum breaks when using Windows-1251 Cyrillic/Russian encoding

It looks like Discourse forums don’t load if the character encoding is set to Windows-1251 for Russian.

To reproduce, set the character encoding to “Cyrillic (Windows-1251)” and visit the homepage of a forum. It will just be a blank page. There are error messages in the console that look something like this:

Uncaught SyntaxError: Invalid regular expression: 
/^[^A-Za-zГЂ-ÖØ-Г¶Гё-КёМЂ-Цђа Ђ-бїїв°Ђ-п¬њп·ѕ-п№Їп»Ѕ-пїї]*[Ц‘-Яїп¬ќ-п·Ѕп№°-п»ј]/: 
Range out of order in character class
    at new RegExp (<anonymous>)

(I’ve only tried it with two Discourse forums – Meta Discourse and my main forum.)

Why would you do that? Discourse uses UTF-8 and that works for Russian too.

I wouldn’t do it myself. :slight_smile:

A user in Russia was getting a blank page. It took several hours to track down the cause and I couldn’t reproduce it until I set my browser’s encoding to Windows-1251.

I’m wondering if other Russian language users are experiencing blank pages. It’s apparently set on his computer at the OS level (Windows), and there isn’t an easy way to change a browser’s character encoding any more without some manual configuration. The browsers’ encoding auto-detection features aren’t working well. We tried Chrome and Firefox.

We have several forums working in Russia. There is no problem if, as written above, UTF-8 is used. We did not experiment or set the encoding Windows-1251. What for? UTF-8 works for everything.

There was no blank page on any of the forums. The browser does not switch to windows-1251.

I tried in 3 browsers to force to expose Windows-1251. If the forum is in utf-8 we only gets the wrong encoding. A blank page is not observed.

cp1251 isn’t dead yet, so I’m not stunned to hear that some users still have a browser which defaults to it.

As of this month(16/12/19) a little over 11% of .ru sites use windows-1251.

I’m not sure why you aren’t seeing it there. I used this browser plugin in Chromium to test it. (Firefox seems to disable the character encoding menu on some sites.)

I just tried with a third Discourse forum, and that one doesn’t load either.

I don’t know why that user has the OS set to Windows-1251. I’m going to try to find out how often it’s happening.

Interesting, please look, with this plugin there is a white page on the forum: https://toxu.ru I watched the encoding windows-1251 on this site.

When I visit your site and set it to Windows-1251, I get a blank page and these errors (same as the other sites).

I’ve just heard an update from the user though — they are using Windows XP with Chrome 49, so that is probably the source of the problem.

I did a quick search through the analytics and there have been 281 visits by 85 users on Windows XP in the past 28 days. I don’t feel like our site needs to support Windows XP, but I’d like to figure out a way to at least serve those people a “please upgrade your browser to use this site” message.

I’m going to recommend that this user upgrades the OS, at least to Linux.

Chrome dropped XP in April 2016. Firefox dropped in June 2018 so it’s a better alternative than Chrome. But in the end the user should upgrade ASAP.

I’m going to warn them about the security risks and offer to assist with Linux if they want to do that.

During the debugging I made a long list of everything to check for when those requests come in. I need to add “Windows NT 5.1” and browser versions to the list for next time.