Skip to content

Commit

Permalink
Remove link confirmation page for URLs in machi.to threads (#1246)
Browse files Browse the repository at this point in the history
まちBBS(machi.to)のスレッドにあるURLからリンク先の
確認ページを表示するURLを取り除くように修正します。

修正前はまちBBSでofflaw.cgiを使わないモードでスレッドを
読み込むと通常リンク(青)をクリックしたときリンク先の
確認ページが開かれるようになっていました。
  • Loading branch information
ma8ma committed Sep 9, 2023
1 parent e919a8e commit 18108c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/dbtree/nodetreebase.cpp
Expand Up @@ -4022,6 +4022,9 @@ bool NodeTreeBase::remove_imenu( std::string& str_link )
|| str_link.compare( host_start, 7, "nun.nu/" ) == 0 ) {
cut_end = host_start + 7;
}
else if( str_link.compare( host_start, 26, "machi.to/bbs/link.cgi?URL=" ) == 0 ) {
cut_end = host_start + 26;
}
else {
return false;
}
Expand Down
17 changes: 17 additions & 0 deletions test/gtest_dbtree_nodetreebase.cpp
Expand Up @@ -30,6 +30,7 @@ TEST_F(NodeTreeBase_RemoveImenuTest, not_remove)
{ "https://jump.5ch.net/?", "https://jump.5ch.net/?" },
{ "https://jump.2ch.net/?", "https://jump.2ch.net/?" },
{ "https://pinktower.com/", "https://pinktower.com/" },
{ "http://machi.to/bbs/link.cgi?URL=", "http://machi.to/bbs/link.cgi?URL=" },
};

std::string buffer;
Expand Down Expand Up @@ -136,4 +137,20 @@ TEST_F(NodeTreeBase_RemoveImenuTest, single_jump_2ch_net)
}
}

TEST_F(NodeTreeBase_RemoveImenuTest, single_machi_to_bbs_link_cgi)
{
constexpr const char* test_data[][2] = {
{ "http://machi.to/bbs/link.cgi?URL=https://foobar.baz", "https://foobar.baz" },
{ "https://machi.to/bbs/link.cgi?URL=http://foobar.baz", "http://foobar.baz" },
{ "http://machi.to/bbs/link.cgi?URL=foobar.baz", "http://foobar.baz" },
};

std::string buffer;
for( auto [input, expect] : test_data ) {
buffer.assign( input );
EXPECT_TRUE( DBTREE::NodeTreeBase::remove_imenu( buffer ) );
EXPECT_EQ( expect, buffer );
}
}

} // namespace

0 comments on commit 18108c9

Please sign in to comment.