Skip to content

Instantly share code, notes, and snippets.

View mikesamuel's full-sized avatar

Mike Samuel mikesamuel

View GitHub Profile
private static final boolean DEBUG_RDS = false;
static void removeDotSegmentsInPlace(StringBuilder path, int left) {
// The code below has excerpts from the spec interspersed.
// The "input buffer" and "output buffer" referred to in the spec
// are both just regions of path.
// The loop deals with the exclusive cases by continuing instead
// of proceeding to the bottom.
boolean isAbsolute = left < path.length() && path.charAt(left) == '/';
// RFC 3986 Section 5.2.4
@mikesamuel
mikesamuel / api.md
Last active October 30, 2017 16:20
API for building URL classifiers

URL Classifier Builder

This is now implemented: https://github.com/OWASP/url-classifier

Problem

Matching URLs with regular expressions is hard. Even experienced programmers who are familiar with the URL spec produce code like /http:\/\/example.com/ which spuriously matches unintended URLs like

@mikesamuel
mikesamuel / hello_world.md
Created August 22, 2017 22:18
Hello, World!

Hello, World!

@mikesamuel
mikesamuel / header-safe-defaults.md
Last active June 19, 2021 04:08
Golang header safe defaults library proposal
@mikesamuel
mikesamuel / auto-noncing-design.md
Last active August 12, 2022 15:09
CSP Auto-noncing in Go html/template

Auto-noncing in Go html/template

Background

CSP mitigates many client-side security vulnerabilities. A policy is a whitelist of locations from which JavaScript, Styles, and other content can be loaded. CSP allows nonces & hashes to make it easy for a policy to allow some inline content without allowing all inline content.