ruckus / quickbooks-ruby

Quickbooks Online REST API V3 - Ruby
MIT License
374 stars 302 forks source link

fix: Reject strings with newlines as being numeric. #543

Closed bcarr092 closed 3 years ago

bcarr092 commented 3 years ago

We ran into a production case where an invoice number contained a newline character. The current method of detecting if the string that contained the newline was returning that the string was in fact numeric when it wasn't. This caused the call to BigNumber to raise an exception.

The proposed fix is to try to parse the value as a BigNumber and if it false use the string value.

ruckus commented 3 years ago

@bcarr092 Thank you! Makes sense.

I wonder if doing the double BigDecimal parsing could be saved by a single parse and a begin/rescue block. But that could also be a premature optimization. I am going to guess its fine in this scenario.

Thanks again.