Tech bro denied dev's hard-earned bonus for bug that overcharged a little old lady
Who, Me? Welcome to the opening day of another working week, an occasion The Register always celebrates with a new installment of Who, Me? It's the Monday column that revisits readers' worst moments at work, and celebrates your ability to rebound and reinvent in their wake.…
Relationship expert warns singles about new 'red flag' dating trend that's worse than ghosting
Are Ukrainians turning on Zelensky?: Multiple casualties reported after civilians 'attack draft officer with bats and metal pipes' in Mykolaiv Oblast
Britain's new immigration hotspots: Up to one in 20 residents in some boroughs are migrants who came here last year - so what is the figure in YOUR area?
How the Queen Mother dealt with grandchildren's divorce misery: The profound effect marriage breakdowns had on the royal, dubbed 'imperial ostrich' over her views - on what would have been her 125th birthday
Revealed: How YouTubers are advising migrants on the best way to win charity visas into Britain for free
Fighter jets scrambled to Trump's New Jersey golf course as president's trip interrupted by SEVEN rogue aircraft
Welcome to Wilderness! Paddleboard yoga, hot tubs and a long table banquet... it can only be the most achingly middle-class festival of 2025
Anger grows over police 'cover-up': We MUST be told the ethnicity of dangerous suspects, Tories warn after alleged rape of 12-year-old girl
Jessie J returned to hospital with ‘infection’ and ‘fluid on my lungs’
Mel B ties the knot... AGAIN! Spice Girl reveals she's celebrated her marriage to husband Rory McPhee with a spiritual ceremony in Morocco
Desperate search launched in Greece after Brit tourist disappears from her sunbed whilst her husband sleeps - as 'police warn her life could be in danger'
Celebrity SAS: Who Dares Wins is thrown into chaos as David Beckham's alleged ex-lover Rebecca Loos gives up on her very first challenge before Louie Spence and Hannah Spearritt QUIT just 30 minutes into opening episode
China’s botched Great Firewall upgrade invites attacks on its censorship infrastructure
China’s attempts to censor traffic carried using Quick UDP Internet Connections (QUIC) are imperfect and have left the country at risk of attacks that degrade its censorship apparatus, or even cut access to offshore DNS resolvers.…
Sudanese asylum seeker living in three-star government hotel 'attempted to kidnap a ten-year-old girl' in front of her father before he was arrested
Three British women are detained in Mauritius after failed bid to smuggle £4million worth of cannabis into the tropical paradise
CodeSOD: Concatenated Validation
User inputs are frequently incorrect, which is why we validate them. So, for example, if the user is allowed to enter an "asset ID" to perform some operation on it, we should verify that the asset ID exists before actually doing the operation.
Someone working with Capybara James almost got there. Almost.
private boolean isAssetIdMatching(String requestedAssetId, String databaseAssetId) { return (requestedAssetId + "").equals(databaseAssetId + ""); }This Java code checks if the requestedAssetId, provided by the user, matches a databaseAssetId, fetched from the database. I don't fully understand how we get to this particular function. How is the databaseAssetId fetched? If the fetch were successful, how could it not match? I fear they may do this in a loop across all of the asset IDs in the database until they find a match, but I don't know that for sure, but the naming conventions hint at a WTF.
The weird thing here, though, is the choice to concatenate an empty string to every value. There's no logical reason to do this. It certainly won't change the equality check. I strongly suspect that the goal here was to protect against null values, but it doesn't work that way in Java. If the string variables are null, this will just throw an exception when you try and concatenate.
I strongly suspect the developer was more confident in JavaScript, where this pattern "works".
I don't understand why or how this function got here. I'm not the only one. James writes:
No clue what the original developers were intending with this. It sure was a shocker when we inherited a ton of code like this.