adamabdelhamed / PowerArgs

The ultimate .NET Standard command line argument parser
MIT License
568 stars 56 forks source link

Fix endless loop when trying to wrap long words #135

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi,

if you call FormatAsTable with a row containing a string that contains a consecutive substring of non-space characters, which is longer than the chosen MaxWidthBeforeWrapping attribute of the SmartWrapOverflowBehavior and is preceded by a space, the FormatAsWrappedSegments method of the ConsoleTableBuilder will go into an endless loop until it has eaten up all the memory.

This pull request introduces a unit test for that and fixes the issue by checking if we are at the beginning of a segment before cutting off a substring.