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

      Using GitHub Copilot in VS Code

      August 4, 2025
      Recent

      Using GitHub Copilot in VS Code

      August 4, 2025

      Optimizely Mission Control – Part I

      August 4, 2025

      Highlights from the 2025 Formula SAE and Formula Student Season

      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

    Rilasciata Debian 12.11: Aggiornamento di Sicurezza e Stabilità

    Linux

    5 Common Mistakes When Creating Design Specs

    Web Development

    CVE-2025-2470 – Nextend Social Login WordPress Plugin Privilege Escalation Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Securing the Future: Best Practices for Data Privacy in AI Projects🔐

    Web Development

    Highlights

    ZealousWeb LLC

    May 12, 2025

    Post Content Source: Read More 

    Melding data, systems, and society

    June 10, 2025

    CVE-2025-4181 – PCMan FTP Server Buffer Overflow Vulnerability

    May 2, 2025

    Copilot Discover Could Soon Redesign News Feed in Windows 11 Widgets

    July 24, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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