Jobsworth council vows not to hand out any more fines for pouring coffee down drain after quashing woman's £150 penalty
SpaceX Disables 2,500 Starlink Terminals Allegedly Used By Asian Scam Centers
Read more of this story at Slashdot.
Kim Kardashian's defiant statement during courtroom showdown with robbers as she tears into vile claim: 'They're saying I was asking for it'
Trump slaps crippling new sanctions on Russia after snubbing meeting with Putin
Maniac who fatally stabbed Ukrainian refugee on a North Carolina train could receive death penalty
Virginia Giuffre's ghostwriter reveals explosive Epstein list time bomb: 'I know all the names'
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."
Quick-thinking NYPD officers save choking baby's life in dramatic video
How dangerous are your hair products? Horrifying risks of popular treatments revealed - as report links Brazilian blow drys to cancer
Kate Middleton and Meghan Markle are making a case for camel trouser suits this autumn - here's where to shop the trend
Did King Charles go far enough in his action against Prince Andrew? Have your say in the Palace Confidential poll
I can't cash £80k insurance policy unless I find my accountant from 50 years ago: CRANE ON THE CASE
Can I get a mortgage to buy a house without having a job?
The Essex area where plans for more than 500 homes have been submitted
Queensland STOPS transgender kids accessing puberty blockers - as mum launches court battle against ruling
The biggest heart health breakthrough since statins? Largest study to date shows Ozempic can dramatically lower risk of major heart problems regardless of weight lost
IBM is just not into the 'spend megabucks on cloudy GPUs' thing, rents them instead
If IBM reveals improved profit margins or a fresh round of redundancies, AI may be the reason, because Big Blue today revealed that its own “Project Bob” developer assistance tools have improved productivity among its coders by 45 percent.…
Is it risky to buy a flat with a 51 year-old lease and will it be costly to extend it?
Eyesore area in Essex town to get complete revamp in new council deal
With impeccable timing, AWS debuts automated cloud incident report generator
In the same week that a massive outage of its own cloud inconvenienced millions of customers, AWS has delivered an improved interactive incident reporting service to help its customers explain what happened when their cloud-hosted resources strike trouble.…