Created
March 5, 2014 16:38
-
-
Save robinsmidsrod/9370894 to your computer and use it in GitHub Desktop.
Pesudo-code for iPXE URI parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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