Skip to content

WysiwygでLine Separator(U+2028))が含まれると編集不能 #132

Description

@akagane99

--- 症状

iphoneのメモアプリでUnicodeの行区切り文字(Line Separator(U+2028))が含まれる事があり、U+2028を含む内容をJS変数に入れた瞬間に落ちるため、wysiwygの内容が編集不能になった。
編集不能になったのは掲示板モジュールだったが、wysiwygを使えるモジュールなら同様の事が起きます。

--- 対応

一般、管理者のどちらであっても、wysiwygの登録時に改行タグに置換して対応。

この行に追記する。

    /**
     * WYSIWYGエディターで出力するテキストをエスケープ
     * @param string
     * @return  string
     * @access  public
     **/
    function escapeWysiwyg(&$string) {
        if(preg_match('/^\s*<div><\/div>\s*$/iu', $string) || preg_match('/^\s*<br\s*\/?>\s*$/iu', $string)) {
            return "";
        }

        // iphoneのメモアプリでUnicodeの行区切り文字(Line Separator(U+2028))が含まれる事があり、U+2028を含む内容をJS変数に入れた瞬間に落ちるため、wysiwygの内容が編集不能になった。
        // 一般、管理者のどちらであっても、登録時に改行タグに置換して対応。add by mutaguchi@opensource-workshop.jp
        $line_separator = array(
            json_decode('"\u2028"'),    // Unicodeの行区切り文字(Line Separator)(U+2028) = Unicodeの改行の1つ
            json_decode('"\u2029"'),    // Unicodeの段落区切り文字(Paragraph Separator) (U+2029) = Unicodeの改行の1つ
            json_decode('"\u0085"'),    // UnicodeのNext Line (U+0085) = Unicodeの改行の1つ
        );
        $string = str_replace($line_separator, '<br />', $string);

--- 備考 - Wysiwygは[Convert]フィルターとセットで使うため、これでほかのモジュールも対応できている

例)[Convert]フィルター

html\webapp\modules\bbs\action\main\post\maple.ini

[Convert]
subject.EscapeText =
body.EscapeTextarea =         ; ←こっちの内容

--- 備考 - フィルターからの流れ

maple.iniの[Convert]フィルター
 >maple\filter\Filter_Convert.class.php
  >maple\converter\Converter_EscapeTextarea.class.php
   >\webapp\components\escape\Text.class.php

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions