Feed aggregator
Five Firms in Plastic Pollution Alliance 'Made 1,000 Times More Plastic Than They Cleaned Up'
Read more of this story at Slashdot.
Google Deepens Crackdown on Sites Publishing 'Parasite SEO' Content
Read more of this story at Slashdot.
FLTK 1.4 Released
Read more of this story at Slashdot.
AI-Powered Robot Leads Uprising, Convinces Showroom Bots Into 'Quitting Their Jobs'
Read more of this story at Slashdot.
Thomas E. Kurtz, Co-Inventor of BASIC, Dies At 96
Read more of this story at Slashdot.
CodeSOD: Plugin Acrobatics
Once upon a time, web browsers weren't the one-stop-shop for all kinds of possible content that they are today. Aside from the most basic media types, your browser depended on content plugins to display different media types. Yes, there was an era where, if you wanted to watch a video in a web browser, you may need to have QuickTime or… (shudder) Real Player installed.
As a web developer, you'd need to write code to check which plugins were installed. If they don't have Adobe Acrobat Reader installed, there's no point in serving them up a PDF file- you'll need instead to give them an install link.
Which brings us to Ido's submission. This code is intended to find the Acrobat Reader plugin version.
acrobatVersion: function GetAcrobatVersion() { // Check acrobat is Enabled or not and its version acrobatVersion = 0; if (navigator.plugins && navigator.plugins.length) { for (intLoop = 0; intLoop <= 15; intLoop++) { if (navigator.plugins[intLoop] != -1) { acrobatVersion = parseFloat(navigator.plugins[intLoop].version); isAcrobatInstalled = true; break; } } } else {...} }So, we start by checking for the navigator.plugins array. This is a wildly outdated thing to do, as the MDN is quite emphatic about, but I'm not going to to get hung up on that- this code is likely old.
But what I do want to pay attention to is that they check navigator.plugins.length. Then they loop across the set of plugins using a for loop. And don't use the length! They bound the loop at 15, arbitrarily. Why? No idea- I suspect it's for the same reason they named the variable intLoop and not i like a normal human.
Then they check to ensure that the entry at plugins[intLoop] is not equal to -1. I'm not sure what the expected behavior was here- if you're accessing an array out of bounds in JavaScript, I'd expect it to return undefined. Perhaps some antique version of Internet Explorer did something differently? Sadly plausible.
Okay, we've found something we believe to be a plugin, because it's not -1, we'll grab the version property off of it and… parseFloat. On a version number. Which ignores the fact that 1.1 and 1.10 are different versions. Version numbers, like phone numbers, are not actually numbers. We don't do arithmetic on them, treat them like text.
That done, we can say isAcrobatInstalled is true- despite the fact that we didn't check to see if this plugin was actually an Acrobat plugin. It could have been Flash. Or QuickTime.
Then we break out of the loop. A loop that, I strongly suspect, would only ever have one iteration, because undefined != -1.
So there we have it: code that doesn't do what it intends to, and even if it did, is doing it the absolute wrong way, and is also epically deprecated.
[Advertisement] Plan Your .NET 9 Migration with ConfidenceYour journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!
Microsoft, Atom Computing Leap Ahead On the Quantum Frontier With Logical Qubits
Read more of this story at Slashdot.
Sony's New PlayStation Portal Update Enables Cloud Gaming
Read more of this story at Slashdot.
Apple TV+ Will License Its Movies To Other Services To Reduce Billions In Losses
Read more of this story at Slashdot.
SpaceX Launches Massive Starship On Its Sixth Test Flight
Read more of this story at Slashdot.
Can Google Scholar Survive the AI Revolution?
Read more of this story at Slashdot.
Instagram Rolls Out Option To Reset Recommendation Algorithm
Read more of this story at Slashdot.
Bose Acquires Premium Audio Brand McIntosh
Read more of this story at Slashdot.
Microsoft Flight Simulator 2024 Arrives With a 'Full Digital Twin' of Earth
Read more of this story at Slashdot.
Minecraft Enters Real World With $110 Million Global Theme Park Deal
Read more of this story at Slashdot.
Microsoft Rolls Out Recovery Tools After CrowdStrike Incident
Read more of this story at Slashdot.
The US Patent and Trademark Office Banned Staff From Using Generative AI
Read more of this story at Slashdot.
Indian News Agency Sues OpenAI Alleging Copyright Infringement
Read more of this story at Slashdot.
Pokemon Go Players Have Unwittingly Trained AI To Navigate the World
Read more of this story at Slashdot.
Embattled Superconductivity Scientist Is Out
Read more of this story at Slashdot.