Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 21, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 21, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 21, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 21, 2025

      The best smart glasses unveiled at I/O 2025 weren’t made by Google

      May 21, 2025

      Google’s upcoming AI smart glasses may finally convince me to switch to a pair full-time

      May 21, 2025

      I tried Samsung’s Project Moohan XR headset at I/O 2025 – and couldn’t help but smile

      May 21, 2025

      Is Google’s $250-per-month AI subscription plan worth it? Here’s what’s included

      May 21, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      IOT and API Integration With MuleSoft: The Road to Seamless Connectivity

      May 21, 2025
      Recent

      IOT and API Integration With MuleSoft: The Road to Seamless Connectivity

      May 21, 2025

      Celebrating GAAD by Committing to Universal Design: Low Physical Effort

      May 21, 2025

      Celebrating GAAD by Committing to Universal Design: Flexibility in Use

      May 21, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft open-sources Windows Subsystem for Linux at Build 2025

      May 21, 2025
      Recent

      Microsoft open-sources Windows Subsystem for Linux at Build 2025

      May 21, 2025

      Microsoft Brings Grok 3 AI to Azure with Guardrails and Enterprise Controls

      May 21, 2025

      You won’t have to pay a fee to publish apps to Microsoft Store

      May 21, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»Representative Line: Get Explosive

    Representative Line: Get Explosive

    April 3, 2025

    Sean sends us a one-line function that is a delight, if by delight you mean “horror”. You’ll be shocked to know it’s PHP.

    function proget(){foreach($_GET as $k=>$v){if($k=="h"){$GLOBALS["h"]=1;}$p=explode(",",$k);}return($p);} //function to process GET headers
    

    Based on the comment, proget is a shorthand for process_get_parameters. Which is sort of what it does. Sort of.

    Let’s go through this. We iterate across our $_GET parameters using $k for the key, $v for the value, but we never reference the value so forget it exists. We’re iterating across every key. The first thing we check is if a key "h" exists. We don’t look at its value, we just check if it exists, and if it does, we set a global variable. And this, right here, is enough for this to be a WTF. The logic of “set a global variable based on the existence of a query parameter regardless of the value of the query parameter” is… a lot. But then, somehow, this actually gets more out there.

    We explode the key on commas (explode being PHP’s much cooler name for split), which implies… our keys may be lists of values? Which I feel like is an example of someone not understanding what a “key” is. But worse than that, we just do this for every key, and return the results of performing that operation on the last key. Which means that if this function is doing anything at all, it’s entirely dependent on the order of the keys. Which, PHP does order the keys by the order they’re added, which I take to mean that if the URL has query params like ?foo=1&h=0&a,b,c,d=wtf. Or, if we’re being picky about encoding, ?foo=1&h=0&a%2Cb%2Cc%2Cd=wtf. The only good news here is that PHP handles the encoding/decoding for you, so the explode will work as expected.

    This is the kind of bad code that leaves me with lots of questions, and I’m not sure I want any of the answers. How did this happen, and why are questions best left unanswered, because I think the answers might cause more harm.

    [Advertisement] Plan Your .NET 9 Migration with Confidence
    Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleFOSS Weekly #25.14: Fedora 42 COSMIC, OnePackage, AppImage Tools and More Linux Stuff
    Next Article Rilasciato Qt 6.9: il framework per interfacce grafiche si aggiorna con prestazioni potenziate e nuovo supporto emoji

    Related Posts

    News & Updates

    The best smart glasses unveiled at I/O 2025 weren’t made by Google

    May 21, 2025
    News & Updates

    Google’s upcoming AI smart glasses may finally convince me to switch to a pair full-time

    May 21, 2025
    Leave A Reply Cancel Reply

    Hostinger

    Continue Reading

    An Introduction to Docker and Containers for Beginners

    Development

    Gaze-LLE: A New AI Model for Gaze Target Estimation Built on Top of a Frozen Visual Foundation Model

    Development

    Selenium – How to remove &nbsp from my text value

    Development

    Mozilla Thunderbird Pro: un client email open source che evolve in una piattaforma completa

    Linux

    Highlights

    Development

    Healthcare Information Architecture: 4 Ways It Can Benefit Your Organization’s Digital Experience

    June 24, 2024

    Your healthcare organization (HCO) could have the best content imaginable on your website. But if…

    Understand the benefits of physical replication in Amazon RDS for PostgreSQL Blue/Green Deployments

    December 18, 2024

    Unlocking Literacy: Ojje’s Journey With MongoDB

    May 15, 2025

    CVE-2025-4242 – PHPGurukul Online Birth Certificate System SQL Injection Vulnerability

    May 3, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.