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

      15 Essential Skills to Look for When Hiring Node.js Developers for Enterprise Projects (2025-2026)

      August 4, 2025

      African training program creates developers with cloud-native skills

      August 4, 2025

      React.js for SaaS Platforms: How Top Development Teams Help Startups Launch Faster

      August 3, 2025

      Upwork Freelancers vs Dedicated React.js Teams: What’s Better for Your Project in 2025?

      August 1, 2025

      LastPass can now warn or block logins to shadow SaaS apps – here’s how

      August 4, 2025

      Get up to a year of Adobe Creative Cloud access for 40% off

      August 4, 2025

      Got 6 hours? This free AI training from Google and Goodwill can boost your resume today

      August 4, 2025

      Why I recommend this budget phone with a paper-like screen over ‘minimalist’ devices

      August 4, 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

      Laravel Boost, your AI coding starter kit

      August 4, 2025
      Recent

      Laravel Boost, your AI coding starter kit

      August 4, 2025

      Using GitHub Copilot in VS Code

      August 4, 2025

      Optimizely Mission Control – Part I

      August 4, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Top 20 kubectl Commands Every Kubernetes Beginner Must Know

      August 4, 2025
      Recent

      Top 20 kubectl Commands Every Kubernetes Beginner Must Know

      August 4, 2025

      Microsoft’s record stock run collides with Nadella’s admission that 15,000 layoffs still ‘hurt’

      August 4, 2025

      Microsoft and Adobe Power Up Fantasy Premier League Fans with AI – Here’s How

      August 4, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Concatenated Validation

    CodeSOD: Concatenated Validation

    August 4, 2025

    User inputs are frequently incorrect, which is why we validate them. So, for example, if the user is allowed to enter an “asset ID” to perform some operation on it, we should verify that the asset ID exists before actually doing the operation.

    Someone working with Capybara James almost got there. Almost.

    private boolean isAssetIdMatching(String requestedAssetId, String databaseAssetId) {
        return (requestedAssetId + "").equals(databaseAssetId + "");
    }
    

    This Java code checks if the requestedAssetId, provided by the user, matches a databaseAssetId, fetched from the database. I don’t fully understand how we get to this particular function. How is the databaseAssetId fetched? If the fetch were successful, how could it not match? I fear they may do this in a loop across all of the asset IDs in the database until they find a match, but I don’t know that for sure, but the naming conventions hint at a WTF.

    The weird thing here, though, is the choice to concatenate an empty string to every value. There’s no logical reason to do this. It certainly won’t change the equality check. I strongly suspect that the goal here was to protect against null values, but it doesn’t work that way in Java. If the string variables are null, this will just throw an exception when you try and concatenate.

    I strongly suspect the developer was more confident in JavaScript, where this pattern “works”.

    I don’t understand why or how this function got here. I’m not the only one. James writes:

    No clue what the original developers were intending with this. It sure was a shocker when we inherited a ton of code like this.

    [Advertisement]
    ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleUnplugging these 7 common household devices helped reduce my electricity bills
    Next Article Tamari – fully-featured recipe manager

    Related Posts

    News & Updates

    LastPass can now warn or block logins to shadow SaaS apps – here’s how

    August 4, 2025
    News & Updates

    Get up to a year of Adobe Creative Cloud access for 40% off

    August 4, 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-3504 – WP Maps Stored Cross-Site Scripting Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-20275 – Cisco Unified Contact Center Express Java Deserialization Code Execution Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Critical RCE Vulnerability in Erlang/OTP SSH Server Impacts Multiple Cisco Products

    Security

    The Lenovo Legion Go (Z1E) PC gaming handheld is $200 cheaper with this Best Buy anti-Prime Day deal — it’s still my favorite handheld

    News & Updates

    Highlights

    Linux

    Rilasciata SteamOS 3.7.8: Miglioramenti e Nuove Funzionalità

    May 26, 2025

    Valve ha rilasciato SteamOS 3.7.8, la prima versione stabile della serie 3.7. Il sistema operativo…

    Are We Ready for Production-Grade Apps With Vibe Coding? A Look at the Replit Fiasco

    July 22, 2025

    Microsoft warns of banking malware targeting German speakers

    April 9, 2025

    Even though Xbox is losing the console war, ironically, it is the console war that makes it superior, gamers agree

    April 9, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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