Regex Injection

Public preview

Want everyone on your software team to learn this? Free 14-day trial.

Train my team
regex-validation.py
Python
@app.route('/share/<path:link>')
def share(link):
  """Return the meta-data for a web-link shared by a user."""

  # Validate the URL has a protocol using a regular expression.
  link = link if re.match("^[a-z]+://.*", link) else f"https://{link}"

  # Go grab the meta-data.
  return OpenGraph(url=link).to_json()