Skip to content

Instantly share code, notes, and snippets.

@robinsmidsrod
Created March 5, 2014 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinsmidsrod/9370894 to your computer and use it in GitHub Desktop.
Save robinsmidsrod/9370894 to your computer and use it in GitHub Desktop.
Pesudo-code for iPXE URI parser
cleanup(url)
split_url(url)
cleanup_decoded_url(decoded_url)
cleanup(url) {
# percent_encode all chars <= 0x20
# percent_encode all chars >= 128
}
split_url(url) {
# everything up to ':' in .scheme
# skip '://'
# everything up to '/' in .server
# everything up to '?' in .path
# skip '?'
# everything up to '#' in .query
# skip '#'
# everything else in .frag
}
cleanup_decoded_url(url) {
# percent_decode .scheme
# percent_decode .server
# strip control chars in .scheme
# strip control chars in .server
# lowercase .scheme
# lowercase .server
if ( .scheme not match '^http' ) {
# percent_decode .path
# remove control chars in .path
}
}
uristring.format {
# loop through bytes in string
# if not ALPHA / DIGIT / "-" / "." / "_" / "~"
# percent_encode byte
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment