Feed aggregator
Microsoft Demands 30% Profit Margins from Struggling Xbox Division
Read more of this story at Slashdot.
Apple Readies New Framework To Let iPhone Users Migrate App Data To Android
Read more of this story at Slashdot.
SpaceX Disables 2,500 Starlink Terminals Allegedly Used By Asian Scam Centers
Read more of this story at Slashdot.
CodeSOD: This Is Really Empty
Konrad was trying to understand how an input form worked, and found this validation function.
function IsReallyEmpty($subject) { $trimmed = trim(preg_replace("/&.*;/", "", $subject)); return strlen($trimmed) != 0; }Now, I can understand why one might want to have a different definition of "empty" when it comes to strings. An all whitespace string, like " " may rightfully be considered an empty input for many applications.
So calling trim makes a lot of sense. It's the preg_replace that starts to worry me, because that regex is clearly trying to match an HTML entity, aka . But it matches all HTML entities, not just ones like which are whitespace characters, but ampersands and greater/less-than signs.
But there's another problem with the regex. The * operator is greedy. So Hello World would see the opening &, the closing ; and decide the entire string could be rejected.
But that's not the real WTF. The real WTF is the very last line. In a function called IsReallyEmpty, it returns true if the input string is not empty, thus stretching the definition of "really" to new levels.
"Is this string really empty?" "No, it is."
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!A SiriusXM Update Sent Some Audi Screens Into a Forced-Reboot Loop For Months
Read more of this story at Slashdot.
Meta Lays Off 600 From 'Bloated' AI Unit
Read more of this story at Slashdot.
Pitchfork Is Beta Testing User Reviews and Comments As It Approaches 30
Read more of this story at Slashdot.
Google Porting All Internal Workloads To Arm
Read more of this story at Slashdot.
AI Assistants Misrepresent News Content 45% of the Time
Read more of this story at Slashdot.
OpenBSD 7.8 Released
Read more of this story at Slashdot.
Samsung Galaxy XR Is the First Android XR Headset
Read more of this story at Slashdot.
Jaguar Land Rover Hack Cost UK Economy an Estimated $2.5 Billion
Read more of this story at Slashdot.
Global Use of Coal Hit Record High in 2024
Read more of this story at Slashdot.
YouTube Will Help You Quit Watching Shorts
Read more of this story at Slashdot.
New Delhi Pollution Hits Five-Year High
Read more of this story at Slashdot.
Apple and Google Face Enforced Changes Over UK Smartphone Dominance
Read more of this story at Slashdot.
Reddit Sues Perplexity For Scraping Data To Train AI System
Read more of this story at Slashdot.
Meta Allows Deepfake of Irish Presidential Candidate To Spread for 12 Hours Before Removal
Read more of this story at Slashdot.
Uber Will Pay Drivers $4,000 To Switch To EVs
Read more of this story at Slashdot.
Google's Quantum Computer Makes a Big Technical Leap
Read more of this story at Slashdot.
