aegirhall / console-menu

A simple Python menu system for building terminal user interfaces.
MIT License
365 stars 58 forks source link

Fix width out-of-bounds issues #99

Open tony-osibov opened 5 months ago

tony-osibov commented 5 months ago

In _format_content there is the possibility that the width value evaluates to a negative value which will throw a ValueError: Sign not allowed in string format specifier. Adding a minimum 0 value ensures that only positive values are used during string formatting.

In calculate_content_width the returned value can result in a value less than 1 which causes issues. Ensuring a value of 1 or greater solves this.