Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
slapos slapos
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Labels
    • Labels
  • Merge requests 122
    • Merge requests 122
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • slaposslapos
  • Merge requests
  • !1495

Merged
Created Dec 18, 2023 by Titouan Soulard@tsoulardDeveloper

software/rapid-cdn: avoid RegExp to validate hostnames

  • Overview 3
  • Commits 1
  • Changes 2

Problem

Requesting a frontend with domain name rapid.university or просто.рф triggers a warning because these domains do not pass the RegExp check ^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}$. For the first domain, the behaviour is opposed to RFC1123, which allows TLDs of at least 63 characters, and strongly suggests not to limit anything less than 255 characters (see section 2.1). For the second domain, called an Internationalized Domain Name, the feature is recent-ish, and was introduced by RFC5890.

Proposed change

Using RegExp to validate hostnames is a bad practice, and has a lot of reasons to be wrong. On top of that, the JSON Schema specification allows, since draft 7, to validate hostnames against an IDN hostname, by using the idn-hostname format (see the string format documentation).

I suggest to use this format instead of our current RegExp check, so that we support all TLDs, and now just those with less than 6 characters (why?), and allow IDNs.

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: patterns-for-dummies
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7