現在のページの位置: くろねこスクエア Labs >

くろねこスクエア Labs

SimplePieでURLのクエリ文字列を読み込む

SimplePie(1.2)がURLのクエリ文字列を受け付けないので、当該箇所を見てsimplepie.incを変更してみます。

1
2
#$this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?');
$this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?&=');

に変更。これによって新しい問題が出そうですが、それよりもクエリ文字列を読み込めないことの方が問題なのです。

feedcreator.class.phpでマルチバイト対応

今更なのですが、以前feedcreator.class.php(1.7.2-ppt)を置き換えた際にマルチバイト対応が抜けていたことに気づきました。以下のように、substr()をmb_strimwidth()に置き換えれば対処できます。

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
    function iTrunc($string, $length) {
        if (strlen($string)<=$length) {
            return $string;
        }
       
        $pos = strrpos($string,".");
        if ($pos>=$length-4) {
            $string = substr($string,0,$length-4);
            $pos = strrpos($string,".");
        }
        if ($pos>=$length*0.4) {
            return mb_strimwidth($string,0,$pos+1," ...");
            #return substr($string,0,$pos+1)." ...";
        }

        $pos = strrpos($string," ");
        if ($pos>=$length-4) {
            $string = substr($string,0,$length-4);
            $pos = strrpos($string," ");
        }
        if ($pos>=$length*0.4) {
            return mb_strimwidth($string,0,$pos," ...");
            #return substr($string,0,$pos)." ...";
        }

        return mb_strimwidth($string,0,$length-4," ...");
        #return substr($string,0,$length-4)." ...";
    }

カテゴリー

Feed

メタ情報