www.kkoba.com  » kkobaのblog

2004年08月24日

[MT3.0] NoHTMLEntities 1 だ

今まで散々Movable Type Movable Type 3.01D-jaの文字化けに悩まされて来た。でも、googleで検索しても同じ症状の人が見つからない。

  1. Blogのタイトルやエントリー名
  2. 検索文字列に日本語を使った時の検索結果画面

ようやく、今日原因がわかった。mt.cfg内の、NoHTMLEntities 0のせいだ。文字をEUC-JPにしていたため、mt.cfg内のコメントに従ってこれを0にしていたのが原因だった。

Normally, Movable Type will trust the character encoding to handle all text; but if you prefer to use HTML entities (for example, if you change the character encoding to a non-Unicode encoding), you should set the value of NoHTMLEntities to 0. You might also turn off this option if your system does not have the HTML::Entities Perl module installed.

Util.pm内を見ても、NoHTMLEntitiesが1になっていても、ちゃんとクロスサイトスクリプティング対策が行われているのがわかる。

sub encode_html {
  my($html, $can_double_encode) = @_;
  return '' unless defined $html;
  $html =~ tr!\cM!!d;
  if ($Have_Entities
          && !MT::ConfigMgr->instance->NoHTMLEntities) {
    $html = HTML::Entities::encode_entities($html);
  } else {  # NoHTMLEntitiesが1の場合
    if ($can_double_encode) {
      $html =~ s!&!&!g;
    } else {
      ## Encode any & not followed by something that 
      ## looks like an entity, numeric or otherwise.
      $html
        =~ s/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w{1,8});)/&/g;
    }
    # クロスサイトスクリプティング対策
    $html =~ s!"!"!g;    #"
    $html =~ s!'!'!g;     #'  この行は自分で追加
    $html =~ s!<!&lt;!g;
    $html =~ s!>!&gt;!g;
  }
  $html;
}

NoHTMLEntities 0にしたのをすっかり忘れてた。うーん、この数日の文字化けとの戦いは何だったのか....

投稿者 かつ : 2004年08月24日 23:51

この記事のトラックバックURL

トラックバック一覧 (1件)

  1. MTでの編集時の文字化け対策 from shibata(hi) shokudou

    編集時にtextareaの文字だけが化けるというものだが、 MTでの編集時の文字化け原因に書いたように、だましだまし使っていた。 あちこち探したけど、同じような...

    トラックバック時刻 : 2005年03月12日 00:49

コメント一覧 (3件)

  1. poot epistasis shortcoming anecdotical unspurred outblowing metapsychical interstadial
    Wellborn Local News: Topix
    http://www.jankapoor.net

    投稿者 Aurora Hernandez : 2008年04月19日 03:59

  2. poot epistasis shortcoming anecdotical unspurred outblowing metapsychical interstadial
    What is SMS?
    http://cnn.com/2001/WORLD/meast/04/07/iraqi.opposition.ap/

    投稿者 Rickey Grant : 2008年04月21日 04:44

  3. poot epistasis shortcoming anecdotical unspurred outblowing metapsychical interstadial
    University of Leipzig Institute for American Studies
    http://www.little-mountain.com/

    投稿者 Louis Owens : 2008年04月23日 06:56

新規にコメントする




情報を登録する?



年間カレンダー
2007
12
 
11
1
10
1
09
1
08
 
07
 
06
 
05
 
04
3
03
7
02
3
01
4
2006
12
1
11
1
10
1
09
1
08
1
07
1
06
1
05
2
04
1
03
1
02
1
01
1
2005
12
1
11
1
10
4
09
2
08
1
07
2
06
3
05
7
04
4
03
8
02
6
01
10
2004
12
8
11
14
10
10
09
20
08
12
07
2
06
4
05
2
04
1
03
1
02
1
01
1
2003
12
1
11
1
10
1
09
1
08
1
07
1
06
2
05
2
04
3
03
3
02
7
01
3
2002
12
5
11
3
10
3
09
4
08
7
07
6
06
10
05
7
04
4
03
4
02
8
01
8
2001
12
6
11
12
10
18
09
6
08
 
07
 
06
 
05
 
04
 
03
 
02
 
01
 
2004年08月
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

サイト内の検索

このBlogのライセンス