Skip to content

Commit 8defb99

Browse files
committed
[plugin:comment,pcomment] add confug "ALLOW_URL_IN_NAME"
名前欄に URL と ドメイン表記の入力を許可する設定を追加しました。デフォルトで "false"(不許可) になっています。
1 parent 22f210c commit 8defb99

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

xoops_trust_path/modules/xpwiki/plugin/comment.inc.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ function plugin_comment_init () {
2121
$this->cont['PLUGIN_COMMENT_FORMAT_NAME'] = '[[$name]]';
2222
$this->cont['PLUGIN_COMMENT_FORMAT_NOW'] = '&new{$now};';
2323
$this->cont['PLUGIN_COMMENT_FORMAT_STRING'] = "\x08MSG\x08 -- \x08NAME\x08 \x08NOW\x08";
24+
25+
// for spam block
26+
$this->cont['PLUGIN_COMMENT_ALLOW_URL_IN_NAME'] = false;
2427

2528
$this->options = array(
2629
'auth' => FALSE,
@@ -53,6 +56,10 @@ function plugin_comment_action()
5356
$comment = str_replace('$msg', $this->root->vars['msg'], $this->cont['PLUGIN_COMMENT_FORMAT_MSG']);
5457
if(isset($this->root->vars['name']) || ($this->root->vars['nodate'] != '1')) {
5558
$_name = (! isset($this->root->vars['name']) || $this->root->vars['name'] == '') ? $this->root->_no_name : $this->root->vars['name'];
59+
// check name
60+
if (empty($this->cont['PLUGIN_COMMENT_ALLOW_URL_IN_NAME']) && preg_match('#https?://|\b[a-z0-9][a-z0-9_-]+\.[a-z]{2,6}\b#i', $_name)) {
61+
return array('msg'=>'', 'body'=>''); // Do nothing
62+
}
5663
// save name to cookie
5764
if ($_name) { $this->func->save_name2cookie($_name); }
5865
$_name = ($_name == '') ? '' : str_replace('$name', $_name, $this->cont['PLUGIN_COMMENT_FORMAT_NAME']);

xoops_trust_path/modules/xpwiki/plugin/pcomment.inc.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ function plugin_pcomment_init () {
3838
// Update recording page's timestamp instead of parent's page itself
3939
$this->conf['TIMESTAMP'] = 1;
4040

41+
// for spam block
42+
$this->conf['ALLOW_URL_IN_NAME'] = false;
43+
4144
// Template "default"
4245
$this->conf['FORMAT_NAME']['default'] = '[[$name]]';
4346
$this->conf['FORMAT_MSG']['default'] = '$msg';
@@ -323,6 +326,11 @@ function plugin_pcomment_insert()
323326
$msg = str_replace("\x08" . 'USER_CODE' . "\x08", ($this->root->userinfo['uid']? 'uid:' . $this->root->userinfo['uid'] : 'ucd:' . $this->root->userinfo['ucd']), $msg);
324327
$name = (! isset($this->root->vars['name']) || $this->root->vars['name'] == '') ? $this->root->_no_name : $this->root->vars['name'];
325328

329+
// check name
330+
if (empty($this->conf['ALLOW_URL_IN_NAME']) && preg_match('#https?://|\b[a-z0-9][a-z0-9_-]+\.[a-z]{2,6}\b#i', $name)) {
331+
return array('msg'=>'', 'body'=>''); // Do nothing
332+
}
333+
326334
//$this->twitter_post($refer, $name, $msg, $this->func->get_page_uri($refer, TRUE));
327335
if (! empty($this->root->post['twitter'])) {
328336
$twitter_msg = $msg;

0 commit comments

Comments
 (0)