Skip to content

Commit

Permalink
fix: added trim to avoid questions with a single space
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Jan 27, 2023
1 parent c4299f6 commit a67dca4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions phpmyfaq/ajaxservice.php
Expand Up @@ -317,21 +317,21 @@
$category = new Category($faqConfig);
$questionObject = new Question($faqConfig);

$author = Filter::filterInput(INPUT_POST, 'name', FILTER_UNSAFE_RAW);
$email = Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
$author = trim(Filter::filterInput(INPUT_POST, 'name', FILTER_UNSAFE_RAW));
$email = trim(Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL));
$faqId = Filter::filterInput(INPUT_POST, 'faqid', FILTER_VALIDATE_INT);
$faqLanguage = Filter::filterInput(INPUT_POST, 'lang', FILTER_UNSAFE_RAW);
$question = Filter::filterInput(INPUT_POST, 'question', FILTER_UNSAFE_RAW);
$question = strip_tags($question);
$question = trim(strip_tags($question));
if ($faqConfig->get('main.enableWysiwygEditorFrontend')) {
$answer = Filter::filterInput(INPUT_POST, 'answer', FILTER_SANITIZE_SPECIAL_CHARS);
$answer = html_entity_decode($answer);
$answer = trim(html_entity_decode($answer));
} else {
$answer = Filter::filterInput(INPUT_POST, 'answer', FILTER_UNSAFE_RAW);
$answer = strip_tags($answer);
$answer = nl2br($answer);
$answer = trim(nl2br($answer));
}
$translatedAnswer = Filter::filterInput(INPUT_POST, 'translated_answer', FILTER_UNSAFE_RAW);
$translatedAnswer = trim(Filter::filterInput(INPUT_POST, 'translated_answer', FILTER_UNSAFE_RAW));
$contentLink = Filter::filterInput(INPUT_POST, 'contentlink', FILTER_UNSAFE_RAW);
$contentLink = Filter::filterVar($contentLink, FILTER_VALIDATE_URL);
$keywords = Filter::filterInput(INPUT_POST, 'keywords', FILTER_UNSAFE_RAW);
Expand Down Expand Up @@ -478,11 +478,11 @@
$faq = new Faq($faqConfig);
$cat = new Category($faqConfig);
$categories = $cat->getAllCategories();
$author = Filter::filterInput(INPUT_POST, 'name', FILTER_UNSAFE_RAW);
$email = Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
$author = trim(Filter::filterInput(INPUT_POST, 'name', FILTER_UNSAFE_RAW));
$email = trim(Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL));
$ucategory = Filter::filterInput(INPUT_POST, 'category', FILTER_VALIDATE_INT);
$question = Filter::filterInput(INPUT_POST, 'question', FILTER_UNSAFE_RAW);
$question = strip_tags($question);
$question = trim(strip_tags($question));
$save = Filter::filterInput(INPUT_POST, 'save', FILTER_VALIDATE_INT, 0);

// If e-mail address is set to optional
Expand Down

0 comments on commit a67dca4

Please sign in to comment.