View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0003381||Ham Radio Deluxe||Maintenance||public||2019-07-08 14:53||2019-11-08 02:31|
|Priority||normal||Severity||minor||Reproducibility||have not tried|
|Target Version||Fixed in Version||184.108.40.206|
|Summary||0003381: double calls to CString::Trim throughout code base, apparently due to careless search and replace|
|Description||A best practice is to treat any external input as dirty: data that must be verified and cleaned before trusted and used. One simple edit is to trim whitespace from the ends of strings. " Hello" is, after all, a different string than "Hello", and users almost never mean to keep the trailing or leading whitespace.|
While investigating an un-related issue, I noticed Change 0001668:
The only description I have for this change, which touches about 250 different files, is the comment "trimming stuff.. shit" so I have little insight into the motivation for the change or the desired effect.
Investigating the change, I see that about 800 lines of code which call TrimRight() or TrimLeft() to trim the whitespace from the right end or the left end (respectively) of a string were replaced with a call to "Trim()". Since I have no insight into the reasoning for the change, I can't be sure, but it seems to me to have been carelessly executed and ill-advised.
If we have this code:
it's pretty clear that we wanted to trim both the leading and trailing whitespace. It's correct to replace that with a single call:
is less source code, less object code, and a bit faster.
However, the search-and-replace operation that I assume took place changed it to this:
Trimming both leading and trailing whitepsace twice in a row doesn't make sense. Only one call is necessary. I had always noticed such doubled calls in the code, but never knew why until I discovered Change 0001668.
I'm worried that other bugs are possible. Since the replacement blindly swapped "TrimRight" for "Trim", for example, it's possible that the code wanted leading white space to remain and became buggy after this careless search-and-replace work.
|Tags||No tags attached.|
fixed with this checkin in the 6.7 branch:
||Taking the developer's account as valid.|
|2019-07-08 14:53||K7ZCZ||New Issue|
|2019-07-08 16:11||K7ZCZ||Assigned To||=> K7ZCZ|
|2019-07-08 16:11||K7ZCZ||Status||new => resolved|
|2019-07-08 16:11||K7ZCZ||Resolution||open => fixed|
|2019-07-08 16:11||K7ZCZ||Note Added: 0008207|
|2019-08-30 15:16||K7ZCZ||Fixed in Version||=> 220.127.116.11|
|2019-09-07 09:09||WA9PIE||Status||resolved => closed|
|2019-09-07 09:09||WA9PIE||Description Updated||View Revisions|
|2019-09-07 09:09||WA9PIE||Testing||Not Started => N/A|
|2019-09-07 09:09||WA9PIE||Note Added: 0008532|
|2019-11-08 02:16||WA9PIE||Fixed in Version||18.104.22.168 => 22.214.171.124|
|2019-11-08 02:31||WA9PIE||Project||3 - Current Dev List => Ham Radio Deluxe|