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

      Error’d: Pickup Sticklers

      September 27, 2025

      From Prompt To Partner: Designing Your Custom AI Assistant

      September 27, 2025

      Microsoft unveils reimagined Marketplace for cloud solutions, AI apps, and more

      September 27, 2025

      Design Dialects: Breaking the Rules, Not the System

      September 27, 2025

      Building personal apps with open source and AI

      September 12, 2025

      What Can We Actually Do With corner-shape?

      September 12, 2025

      Craft, Clarity, and Care: The Story and Work of Mengchu Yao

      September 12, 2025

      Cailabs secures €57M to accelerate growth and industrial scale-up

      September 12, 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 phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025
      Recent

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025

      Mastering PHP File Uploads: A Guide to php.ini Settings and Code Examples

      September 28, 2025

      The first browser with JavaScript landed 30 years ago

      September 27, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured
      Recent
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: The XML Dating Service

    CodeSOD: The XML Dating Service

    July 9, 2025

    One of the endless struggles in writing reusable API endpoints is creating useful schemas to describe them. Each new serialization format comes up with new ways to express your constraints, each with their own quirks and footguns and absolute trainwrecks.

    Maarten has the “pleasure” of consuming an XML-based API, provided by a third party. It comes with an XML schema, for validation. Now, the XML Schema Language has a large number of validators built in. For example, if you want to restrict a field to being a date, you can mark it’s type as xsd:date. This will enforce a YYYY-MM-DD format on the data.

    If you want to ruin that validation, you can do what the vendor did:

    <span class="hljs-tag"><<span class="hljs-name">xsd:simpleType</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"DatumType"</span>></span>
      <span class="hljs-tag"><<span class="hljs-name">xsd:annotation</span>></span>
        <span class="hljs-tag"><<span class="hljs-name">xsd:documentation</span>></span>YYYY-MM-DD<span class="hljs-tag"></<span class="hljs-name">xsd:documentation</span>></span>
      <span class="hljs-tag"></<span class="hljs-name">xsd:annotation</span>></span>
      <span class="hljs-tag"><<span class="hljs-name">xsd:restriction</span> <span class="hljs-attr">base</span>=<span class="hljs-string">"xsd:date"</span>></span>
        <span class="hljs-tag"><<span class="hljs-name">xsd:pattern</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"(1|2)[0-9]{3}-(0|1)[0-9]-[0-3][0-9]"</span> /></span>
      <span class="hljs-tag"></<span class="hljs-name">xsd:restriction</span>></span>
    <span class="hljs-tag"></<span class="hljs-name">xsd:simpleType</span>></span>
    

    You can see the xsd:pattern element, which applies a regular expression to validation. And this regex will “validate” dates, excluding things which are definitely not dates, and allowing very valid dates, like February 31st, November 39th, and the 5th of Bureaucracy (the 18th month of the year), as 2025-02-31, 2025-11-39 and 2025-18-05 are all valid strings according to the regex.

    Now, an astute reader will note that this is a xsd:restriction on a date; this means that it’s applied in addition to ensuring the value is a valid date. So this idiocy is harmless. If you removed the xsd:pattern element, the behavior would remain unchanged.

    That leads us to a series of possible conclusions: either they don’t understand how XML schema restrictions work, or they don’t understand how dates work. As to which one applies, well, I’d say 1/3 chance they don’t understand XML, 1/3 chance they don’t understand dates, and a 1/3 chance they don’t understand both.

    [Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleThe Rise of AI Analytics and What It Means for Industries
    Next Article Free Ad Text Generator

    Related Posts

    News & Updates

    Building personal apps with open source and AI

    September 12, 2025
    News & Updates

    What Can We Actually Do With corner-shape?

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

    Microsoft Authenticator to Drop Password Manager Features by August 2025

    Security

    Design Patterns For AI Interfaces

    Tech & Work

    Designer Spotlight: Ivan Ermakov

    News & Updates

    Introducing the Frontier Safety Framework

    Artificial Intelligence

    Highlights

    Update Google Chrome to fix actively exploited zero-day (CVE-2025-6558)

    July 16, 2025

    Update Google Chrome to fix actively exploited zero-day (CVE-2025-6558)

    For the fifth time this year, Google has patched a Chrome zero-day vulnerability (CVE-2025-6558) exploited by attackers in the wild.
    About CVE-2025-6558
    CVE-2025-6558 is a high-severity vulnerability …
    Read more

    Published Date:
    Jul 16, 2025 (5 hours, 9 minutes ago)

    Vulnerabilities has been mentioned in this article.

    CVE-2025-7657

    CVE-2025-7656

    CVE-2025-6558

    Muon Optimizer Significantly Accelerates Grokking in Transformers: Microsoft Researchers Explore Optimizer Influence on Delayed Generalization

    April 23, 2025

    Inroads to personalized AI trip planning

    June 10, 2025

    I tried Google Stitch. Here’s what I loved (and hated) about it

    September 11, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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