FIX: Better and more secure validation of periods for TopicQuery (PR #13834)

Co-authored-by: Martin Brennan mjrbrennan@gmail.com

GitHub