Properly check charset when posting with newsreader via SSL

This commit is contained in:
Retro_Guy 2021-03-17 18:28:41 -07:00
parent 696cbd6f17
commit b95dcb5a00
2 changed files with 20 additions and 3 deletions

View File

@ -1275,9 +1275,13 @@ function get_date_interval($value) {
return $variance; return $variance;
} }
function get_search_snippet($body, $content_type) { function get_search_snippet($body, $content_type='') {
$body = quoted_printable_decode($body); $body = quoted_printable_decode($body);
$mysnippet = recode_charset($body, $content_type, "utf8"); if($content_type !== '') {
$mysnippet = recode_charset($body, $content_type, "utf8");
} else {
$mysnippet = $body;
}
if($bodyend=strrpos($mysnippet, "\n---\n")) { if($bodyend=strrpos($mysnippet, "\n---\n")) {
$mysnippet = substr($mysnippet, 0, $bodyend); $mysnippet = substr($mysnippet, 0, $bodyend);
} else { } else {

View File

@ -1115,7 +1115,20 @@ $date_i,$mid_i,$references_i,$bytes_i,$lines_i,$xref_i,$body) {
$dbh = null; $dbh = null;
} }
if($CONFIG['article_database'] == '1') { if($CONFIG['article_database'] == '1') {
$this_snippet = get_search_snippet($body, 'UTF8'); foreach($body as $line) {
if(trim($line) == "") {
break;
}
if(stripos($line, "Content-Type: ") === 0) {
preg_match('/.*charset=.*/', $line, $te);
$content_type = explode("Content-Type: text/plain; charset=", $te[0]);
}
}
if(isset($content_type[1])) {
$this_snippet = get_search_snippet($body, $content_type[1]);
} else {
$this_snippet = get_search_snippet($body);
}
$article_dbh = article_db_open($spooldir.'/'.$nntp_group.'-articles.db3'); $article_dbh = article_db_open($spooldir.'/'.$nntp_group.'-articles.db3');
$article_sql = 'INSERT INTO articles(newsgroup, number, msgid, date, name, subject, article, search_snippet) VALUES(?,?,?,?,?,?,?,?)'; $article_sql = 'INSERT INTO articles(newsgroup, number, msgid, date, name, subject, article, search_snippet) VALUES(?,?,?,?,?,?,?,?)';
$article_stmt = $article_dbh->prepare($article_sql); $article_stmt = $article_dbh->prepare($article_sql);