9

!rant
We were finishing another sprint of our grocery shop site at school and it was time for a demo.
There we are, showing our work before the other students. Our teams have a healthy habit of always checking each other not to leave some stoopid mistakes in the final versions, so everybody always regExes and validates THE SHIT out of every input field, both in the view and on the server side. But this one team found out that sometimes it's not enough.

Like every team, they're asked to buy a negative value from their shop. The guy clicks through the process, buys exactly -1 of a banana. He clicks the button to purchase and the site returned "Added banana to the cart!" and we're like "haha n00bz". But someone asked them to show the cart and everyone stopped immediately.

There were 9999 bananas in the cart.

Turns out the member responsible for purchase validation made it add 10000 if the quantity of a bought product was negative.
To this day I can't understand why he did that. xD

Comments
  • 0
    so the user would get 9999 banas and the money of one banana? hilarious 😆
  • 1
    @heyheni He would've had to pay for those 9999 bananas!
  • 0
    Ye olde Integer oveflow :) ...
    Or is it ? 10000 would've been an odd number to overflow on ...
  • 0
    @askerad His code went like this:
    ```
    if (productQuantity < 0) {
    productQuantity += 10000
    }
    ```
    It was totally deliberate. :D
Add Comment