|
Chris Maunder wrote: I just can’t get into
Chris Maunder wrote: Ford F-150’s,
Might I suggest that if you cannot get into a Ford F-150 you lay off the Thanksgiving feast for a while?
I, for one, like Roman Numerals.
|
|
|
|
|
So I just spent an hour figuring out why I was getting an exception in my application when using a third party library to communicate to a credit card processing machine. I was getting a general exception back from the third party library, but the test software that comes with the library was working just fine.
Short answer, when I C&P'd my router's public IP address into the dialog box, there was a space at the end of the IP address. Took a while to spot:
"192.168.14.134 "
vs.
"192.168.14.134"
Sigh. OK, so now I make sure to trim the IP address string (the third party library expects a string) and I suppose I should do some regex validation.
Still, why couldn't I get back an exception like "malformed IP address"? Why is the library so sensitive to an space at the end of string? Yes, I take some responsibility, but not all the responsibility!!!
|
|
|
|
|
Yeah, now try other (valid) variants and see what their code does with them.
Edit:
A .net method/property which takes an IP address as a parameter should take a System.Net.IPAddress rather than a string.
modified 14-Oct-19 23:20pm.
|
|
|
|
|
Marc Clifton wrote: when I C&P'd my router's public IP address into the dialog box
Copy & Paste, indeed! I expect more from you. You should be typing more.
Trim()
Seriously though...it seems really odd (terrible) that they didn't at least do a String.Trim() on the incoming string since it is such a freebie in almost every language (java, C#, javascript). Many more languages have it of course, but it is just named something slightly different.
I never trust user input because I used to do a lot of testing and open input boxes are the best way to break a program.
|
|
|
|
|
raddevus wrote: ...open input boxes are the best way to break a program. Indeed.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Yep, Little Bobby Tables. The newest on this one is real -- the guy who chose NULL for his license plate:
How a 'NULL' License Plate Landed One Hacker in Ticket Hell | WIRED[^]
Summary, every time a cop didn't have the license plate for the ticket a NULL got entered into the database for the license plate. That meant all ticket fines got assigned to the owner with the license plate of NULL.
|
|
|
|
|
In another jurisdiction, "NO PLATE" had the same effect.
|
|
|
|
|
err,
getting back to the OP message then...
if the guy was smarter he would have chosen (without the quotes) "NULL ", " NULL" or " NULL " as his plate.
(ya jus gotta find one of those forms where you enter each letter into a box - excuse for the last 2 "wanted it centered".
Message Signature
(Click to edit ->)
|
|
|
|
|
Marc Clifton wrote: Yes, I take some responsibility, but not all the responsibility!!!
How does that go again? "Be generous in what you accept for input, but strict about what you output..."?
|
|
|
|
|
|
Stringly typing never seems to get out of fashion.Strict typing can be a pain at times, but in the end it's one of your strongest allies. Taking the lazy way out breeds so many small and large horrors, but why waste a thought on it when they waste other people's time?
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
public class IPAddress
{
public int FirstPart { get; set; }
public int SecondPart { get; set; }
public int ThirdPart { get; set; }
public int FourthPart { get; set; }
public override string ToString()
{
return $"{FirstPart}.{SecondPart}.{ThirdPart}.{FourthPart}";
}
}
|
|
|
|
|
We're going to have to wash your mouth out with SOAP young man...
Software Zen: delete this;
|
|
|
|
|
You should see my IPv6 implementation
|
|
|
|
|
public class IPv6Address : IPAddress
{
public int FourthPartSubPartA { set; get; }
public int FourthPartSubPartB { set; get; }
public override string ToString()
{
return $"{FirstPart}:{SecondPart}:{ThirdPart}:{FourthPart}:{FourthPartSubPartA}:{FourthPartSubPartB}";
}
} Something like this, no?
Software Zen: delete this;
|
|
|
|
|
Those trailing space problems get worse when SQL Server gets involved, or the way we have it set up anyway. While a string with a trailing space is completely different to one without in .NET, TSQL matches them both. Causes a key-caching nightmare when not validated!
Regards,
Rob Philpott.
|
|
|
|
|
Not to mention that T-SQL will trim only character 32 and not other "whitespace characters".
And as a bonus, it does the same thing with VARBINARY, not just VARCHAR.
(LEN as well.)
|
|
|
|
|
I was looking for the manual and map that came with an old game. Looks like the box also contained this opportunity[^].
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Unfortunately, the salary is also paid at 1980's rates ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Go get the DeLorean and we just travel back.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
My Flux Capacitor is still printing, it may be a while.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Come over. My BoP is ok and we can use the old 'fly around the sun at warp speed' method.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Sorry - I can't read Klingon.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm curious - what's the game?
/ravi
|
|
|
|
|
This one here.[^] You may want to skip the epic loading procedure, but this was before the days of hard disks for everyone.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|