Computer
OpenAI Buys AI Startup That Built Interface For Apple Computers
Read more of this story at Slashdot.
Anthropic's Google Cloud Deal Includes 1 Million TPUs, 1 GW of Capacity In 2026
Read more of this story at Slashdot.
Trump Eyes Government Control of Quantum Computing Firms
Read more of this story at Slashdot.
Microsoft Puts Office Online Server On the Chopping Block
Read more of this story at Slashdot.
Apple Loses Landmark UK Lawsuit Over App Store Commissions
Read more of this story at Slashdot.
China's New Five-Year Plan Sharpens Industry, Tech Focus
Read more of this story at Slashdot.
Memory Giants Samsung and SK Hynix Push Through 30% Price Increases Amid AI Server Boom
Read more of this story at Slashdot.
Apollo Says AI Energy Gap 'Will Not Be Closed in Our Lifetime'
Read more of this story at Slashdot.
Trump Pardons Binance Founder Changpeng Zhao
Read more of this story at Slashdot.
Three Decades After Clippy, Microsoft Launches Mico
Read more of this story at Slashdot.
McKinsey Says Bank Profits Face Possible $170 Billion AI Hit
Read more of this story at Slashdot.
Overshooting 1.5C Climate Target 'Inevitable': UN Chief
Read more of this story at Slashdot.
Detection Firm Finds 82% of Herbal Remedy Books on Amazon 'Likely Written' By AI
Read more of this story at Slashdot.
Gboard's Latest Update Removes the Period and Comma Keys on Android
Read more of this story at Slashdot.
Fujitsu's New Laptop in Japan Includes Optical Drive Abandoned Elsewhere
Read more of this story at Slashdot.
American E-waste is Causing a 'Hidden Tsunami' in Southeast Asia, Report Says
Read more of this story at Slashdot.
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!