Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[Solved] Cyrillic characters in spoiler tag

edited December 2011 in Vanilla 2.0 - 2.8

All is fine when I use Latin characters:
[spoiler=test]test[/spoiler]
But the spoiler is not displayed correctly when I use the Cyrillic characters:
[spoiler=тест]test[/spoiler]

How can I fix it? I use Vanilla 2.0.18.1. Thanks in advance you for answers.

Tagged:

Best Answer

  • x00x00 MVP
    edited December 2011 Answer ✓

    I think you need the u modifier so

    $Data->Body = preg_replace_callback("/(\[spoiler(?:=\"?([\d\p{L}_',\.\?]+)\"?)?\])/ui", array($this, 'SpoilerCallback'), $Data->Body);
    

    the i modifier makes it case insensitive.

    grep is your friend.

Answers

  • Found the answer. It is necessary to change the line 57:

    $Data->Body = preg_replace_callback("/(\[spoiler(?:=\"?([\d\w_',.? ]+)\"?)?\])/", array($this, 'SpoilerCallback'), $Data->Body);
    

    to:

    $Data->Body = preg_replace_callback("/(\[spoiler(?:=\"?([\d\w_абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ«»',.? ]+)\"?)?\])/", array($this, 'SpoilerCallback'), $Data->Body);
    

    I would be grateful if someone will confirm or disprove the correctness of this decision.

  • x00x00 MVP
    edited December 2011

    use [\d\p{L}_',\.\?]+

    that will match any kind of letter in any language.

    [\d\w\p{Cyrillic}_',\.\?]+

    for Cyrillic and standard Latin

    grep is your friend.

  • edited December 2011

    Sorry, x00, but it doesn't work. Does p{L} and p{Cyrillic} ranges include " character? It may be a cause of problem, I guess.

  • x00x00 MVP
    edited December 2011 Answer ✓

    I think you need the u modifier so

    $Data->Body = preg_replace_callback("/(\[spoiler(?:=\"?([\d\p{L}_',\.\?]+)\"?)?\])/ui", array($this, 'SpoilerCallback'), $Data->Body);
    

    the i modifier makes it case insensitive.

    grep is your friend.

  • you could try а-яА-Я

    grep is your friend.

  • the prior example is dependent on you version of php and PCRE

    grep is your friend.

  • It works with string:

    $Data->Body = preg_replace_callback("/(\[spoiler(?:=\"?([\d\p{L}_\-—«»',.?! ]+)\"?)?\])/ui", array($this, 'SpoilerCallback'), $Data->Body);
    

    Thank you for your help, x00.

  • No worries my friend.

    grep is your friend.

Sign In or Register to comment.