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

      CodeSOD: Identify a Nap

      September 23, 2025

      Ambient Animations In Web Design: Principles And Implementation (Part 1)

      September 23, 2025

      Benchmarking AI-assisted developers (and their tools) for superior AI governance

      September 23, 2025

      Digital.ai launches White-box Cryptography Agent to enable stronger application security

      September 23, 2025

      Development Release: MX Linux 25 Beta 1

      September 22, 2025

      DistroWatch Weekly, Issue 1140

      September 21, 2025

      Distribution Release: DietPi 9.17

      September 21, 2025

      Development Release: Zorin OS 18 Beta

      September 19, 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

      Stop using .reverse().find(): meet findLast()

      September 23, 2025
      Recent

      Stop using .reverse().find(): meet findLast()

      September 23, 2025

      @ts-ignore is almost always the worst option

      September 22, 2025

      MutativeJS v1.3.0 is out with massive performance gains

      September 22, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      How I Configure Polybar to Customize My Linux Desktop

      September 23, 2025
      Recent

      How I Configure Polybar to Customize My Linux Desktop

      September 23, 2025

      Development Release: MX Linux 25 Beta 1

      September 22, 2025

      DistroWatch Weekly, Issue 1140

      September 21, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Objectifying Yourself

    CodeSOD: Objectifying Yourself

    April 28, 2025

    “Boy, stringly typed data is hard to work with. I wish there were some easier way to work with it!”

    This, presumably, is what Gary‘s predecessor said. Followed by, “Wait, I have an idea!”

    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> Object <span class="hljs-title function_">createValue</span><span class="hljs-params">(String string)</span> {
    	<span class="hljs-type">Object</span> <span class="hljs-variable">value</span> <span class="hljs-operator">=</span> parseBoolean(string);
    	<span class="hljs-keyword">if</span> (value != <span class="hljs-literal">null</span>) {
    		<span class="hljs-keyword">return</span> value;
    	}
    
    	value = parseInteger(string);
    	<span class="hljs-keyword">if</span> (value != <span class="hljs-literal">null</span>) {
    		<span class="hljs-keyword">return</span> value;
    	}
    
    	value = parseDouble(string);
    	<span class="hljs-keyword">if</span> (value != <span class="hljs-literal">null</span>) {
    		<span class="hljs-keyword">return</span> value;
    	}
    
    	<span class="hljs-keyword">return</span> string;
    }
    

    This takes a string, and then tries to parse it, first into a boolean, failing that into an integer, and failing that into a double. Otherwise, it returns the original string.

    And it returns an object, which means you still get to guess what’s in there even after this. You just get to guess what it returned, and hope you cast it to the correct type. Which means this almost certainly is called like this:

    <span class="hljs-type">boolean</span> <span class="hljs-variable">myBoolField</span> <span class="hljs-operator">=</span> (Boolean)createValue(someStringContainingABool);
    

    Which makes the whole thing useless, which is fun.

    Gary found this code in a “long since abandoned” project, and I can’t imagine why it ended up getting abandoned.

    [Advertisement]
    Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleDual Booting CachyOS and Windows
    Next Article CVE-2025-4006 – Youyiio BeyongCms Unrestricted File Upload Vulnerability

    Related Posts

    News & Updates

    Development Release: MX Linux 25 Beta 1

    September 22, 2025
    News & Updates

    DistroWatch Weekly, Issue 1140

    September 21, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2025-7813 – “Eventin WordPress Plugin SSRF Vulnerability”

    Common Vulnerabilities and Exposures (CVEs)

    Battlefield 6 community reacts to the multiplayer reveal — player movement, cosmetics, server browser, PC specs, and more

    News & Updates

    After years of requests, Diablo 4’s Paladin might finally be on the horizon — here’s why fans think it’s happening

    News & Updates

    Apple’s gloves-on approach with AI is giving Siri a bad look — Former staffers say it’s a “hot potato” being tossed around AIMLessly

    News & Updates

    Highlights

    CVE-2025-3826 – SourceCodester Web-based Pharmacy Product Management System Cross-Site Scripting Vulnerability

    April 20, 2025

    CVE ID : CVE-2025-3826

    Published : April 20, 2025, 1:15 p.m. | 1 hour, 33 minutes ago

    Description : A vulnerability, which was classified as problematic, was found in SourceCodester Web-based Pharmacy Product Management System 1.0. This affects an unknown part of the file add-supplier.php. The manipulation of the argument txtsupplier_name/txtaddress leads to cross site scripting. It is possible to initiate the attack remotely. The exploit has been disclosed to the public and may be used.

    Severity: 2.4 | LOW

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    Forget ChatGPT? Alibaba’s Qwen3 Might Be the New AI King

    April 29, 2025

    CVE-2025-45859 – TOTOLINK A3002R Buffer Overflow

    May 13, 2025

    HTML-validate – offline HTML5 validator

    August 27, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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