std: Deny overlong encodings in UTF-8
std: Deny overlong encodings in UTF-8

An 'overlong encoding' is a codepoint encoded non-minimally using the
utf-8 format. Denying these enforce each codepoint to have only one
valid representation in utf-8.

An example is byte sequence 0xE0 0x80 0x80 which could be interpreted as
U+0, but it's an overlong encoding since the canonical form is just
0x00.

Another example is 0xE0 0x80 0xAF which was previously accepted and is
an overlong encoding of the solidus "/". Directory traversal characters
like / and . form the most compelling argument for why this commit is
security critical.

Factor out common UTF-8 decoding expressions as macros. This commit will
partly duplicate UTF-8 decoding, so it is now present in both
fn is_utf8() and .char_range_at(); the latter using an assumption of
a valid str.

zaeleus/rust,carols10cents/rust,untitaker/rust,zubron/rust,pelmers/rust,GBGamer/rust,victorvde/rust,jbclements/rust,AerialX/rust,hauleth/rust,graydon/rust,pshc/rust,nham/rust,stepancheg/rust-ide-rust,mitsuhiko/rust,barosl/rust,pshc/rust,mahkoh/rust,vhbit/rust,Ryman/rust,P1start/rust,KokaKiwi/rust,pczarn/rust,jroesch/rust,KokaKiwi/rust,aidancully/rust,erickt/rust,krzysz00/rust,pythonesque/rust,ruud-v-a/rust,krzysz00/rust,omasanori/rust,AerialX/rust-rt-minimal,l0kod/rust,LeoTestard/rust,GBGamer/rust,pythonesque/rust,0x73/rust,defuz/rust,fabricedesre/rust,aepsil0n/rust,zubron/rust,Ryman/rust,mvdnes/rust,aidancully/rust,avdi/rust,nwin/rust,erickt/rust,servo/rust,bombless/rust,kimroen/rust,omasanori/rust,mvdnes/rust,GBGamer/rust,erickt/rust,stepancheg/rust-ide-rust,ebfull/rand,ktossell/rust,aidancully/rust,pythonesque/rust,Ryman/rust,michaelballantyne/rust-gpu,graydon/rust,mvdnes/rust,victorvde/rust,ktossell/rust,pelmers/rust,servo/rust,reem/rust,ebfull/rust,LeoTestard/rust,aturon/rust,stepancheg/rust-ide-rust,nwin/rust,miniupnp/rust,mahkoh/rust,richo/rust,miniupnp/rust,rprichard/rust,untitaker/rust,TheNeikos/rust,miniupnp/rust,zubron/rust,pelmers/rust,zaeleus/rust,richo/rust,fabricedesre/rust,andars/rust,untitaker/rust,andars/rust,philyoon/rust,TheNeikos/rust,XMPPwocky/rust,mihneadb/rust,omasanori/rust,emk/rust,l0kod/rust,jroesch/rust,SiegeLord/rust,dinfuehr/rust,robertg/rust,seanrivera/rust,ebfull/rust,defuz/rust,seanrivera/rust,dinfuehr/rust,richo/rust,mvdnes/rust,reem/rust,michaelballantyne/rust-gpu,waynenilsen/rand,0x73/rust,mihneadb/rust,Ryman/rust,aepsil0n/rust,XMPPwocky/rust,mdinger/rust,mahkoh/rust,jbclements/rust,pshc/rust,kimroen/rust,l0kod/rust,seanrivera/rust,andars/rust,zachwick/rust,zubron/rust,mihneadb/rust,KokaKiwi/rust,omasanori/rust,l0kod/rust,GBGamer/rust,ebfull/rust,barosl/rust,mitsuhiko/rust,michaelballantyne/rust-gpu,pshc/rust,andars/rust,rohitjoshi/rust,retep998/rand,bombless/rust,XMPPwocky/rust,jashank/rust,erickt/rust,ejjeong/rust,robertg/rust,LeoTestard/rust,achanda/rand,fabricedesre/rust,vhbit/rust,philyoon/rust,mihneadb/rust,nwin/rust,bombless/rust,Ryman/rust,cllns/rust,ejjeong/rust,jashank/rust,untitaker/rust,michaelballantyne/rust-gpu,rohitjoshi/rust,dwillmer/rust,TheNeikos/rust,ktossell/rust,defuz/rust,kimroen/rust,robertg/rust,mdinger/rust,mvdnes/rust,robertg/rust,krzysz00/rust,rohitjoshi/rust,quornian/rust,aepsil0n/rust,emk/rust,emk/rust,GBGamer/rust,ruud-v-a/rust,jashank/rust,carols10cents/rust,zubron/rust,KokaKiwi/rust,rprichard/rust,richo/rust,zachwick/rust,hauleth/rust,ebfull/rust,l0kod/rust,seanrivera/rust,AerialX/rust-rt-minimal,0x73/rust,fabricedesre/rust,graydon/rust,servo/rust,rohitjoshi/rust,gifnksm/rust,mahkoh/rust,GrahamDennis/rand,graydon/rust,reem/rust,mitsuhiko/rust,erickt/rust,SiegeLord/rust,ejjeong/rust,zachwick/rust,ktossell/rust,avdi/rust,dwillmer/rust,mihneadb/rust,aneeshusa/rust,miniupnp/rust,vhbit/rust,shepmaster/rand,pshc/rust,ktossell/rust,stepancheg/rust-ide-rust,Ryman/rust,ruud-v-a/rust,aepsil0n/rust,fabricedesre/rust,andars/rust,nwin/rust,pczarn/rust,jroesch/rust,kwantam/rust,ebfull/rust,jbclements/rust,dwillmer/rust,victorvde/rust,omasanori/rust,emk/rust,reem/rust,graydon/rust,barosl/rust,jbclements/rust,0x73/rust,P1start/rust,l0kod/rust,philyoon/rust,cllns/rust,untitaker/rust,philyoon/rust,rohitjoshi/rust,sae-bom/rust,quornian/rust,pshc/rust,P1start/rust,huonw/rand,bombless/rust-docs-chinese,bombless/rust,zachwick/rust,sae-bom/rust,pelmers/rust,zaeleus/rust,vhbit/rust,zubron/rust,vhbit/rust,GBGamer/rust,quornian/rust,avdi/rust,jashank/rust,bombless/rust,andars/rust,aidancully/rust,avdi/rust,nwin/rust,carols10cents/rust,SiegeLord/rust,pshc/rust,dinfuehr/rust,carols10cents/rust,victorvde/rust,mitsuhiko/rust,erickt/rust,michaelballantyne/rust-gpu,zaeleus/rust,aturon/rust,quornian/rust,aidancully/rust,ejjeong/rust,carols10cents/rust,jbclements/rust,0x73/rust,kwantam/rust,zaeleus/rust,philyoon/rust,AerialX/rust,0x73/rust,omasanori/rust,jroesch/rust,cllns/rust,jbclements/rust,LeoTestard/rust,michaelballantyne/rust-gpu,stepancheg/rust-ide-rust,victorvde/rust,defuz/rust,dwillmer/rust,stepancheg/rust-ide-rust,P1start/rust,kwantam/rust,aturon/rust,miniupnp/rust,AerialX/rust-rt-minimal,servo/rust,carols10cents/rust,kwantam/rust,aturon/rust,miniupnp/rust,quornian/rust,bluss/rand,pythonesque/rust,kimroen/rust,emk/rust,zubron/rust,aturon/rust,dinfuehr/rust,nham/rust,hauleth/rust,zachwick/rust,ruud-v-a/rust,barosl/rust,jroesch/rust,jbclements/rust,victorvde/rust,mahkoh/rust,hauleth/rust,graydon/rust,seanrivera/rust,TheNeikos/rust,TheNeikos/rust,krzysz00/rust,aneeshusa/rust,ktossell/rust,robertg/rust,XMPPwocky/rust,nham/rust,ruud-v-a/rust,kimroen/rust,jashank/rust,rprichard/rust,XMPPwocky/rust,dwillmer/rust,GBGamer/rust,AerialX/rust,miniupnp/rust,ktossell/rust,mvdnes/rust,jroesch/rust,arthurprs/rand,jbclements/rust,jroesch/rust,SiegeLord/rust,reem/rust,emk/rust,rohitjoshi/rust,cllns/rust,krzysz00/rust,AerialX/rust,jbclements/rust,nwin/rust,SiegeLord/rust,KokaKiwi/rust,P1start/rust,pczarn/rust,rprichard/rust,sae-bom/rust,kwantam/rust,ejjeong/rust,mitsuhiko/rust,P1start/rust,AerialX/rust-rt-minimal,l0kod/rust,rprichard/rust,miniupnp/rust,P1start/rust,pelmers/rust,untitaker/rust,cllns/rust,mdinger/rust,avdi/rust,aneeshusa/rust,ejjeong/rust,servo/rust,bhickey/rand,zaeleus/rust,dinfuehr/rust,mitsuhiko/rust,pczarn/rust,aturon/rust,aepsil0n/rust,avdi/rust,hauleth/rust,mdinger/rust,sae-bom/rust,richo/rust,LeoTestard/rust,pythonesque/rust,aepsil0n/rust,pczarn/rust,aturon/rust,KokaKiwi/rust,defuz/rust,barosl/rust,reem/rust,aidancully/rust,zachwick/rust,SiegeLord/rust,gifnksm/rust,defuz/rust,ebfull/rust,rprichard/rust,mdinger/rust,michaelballantyne/rust-gpu,mahkoh/rust,pshc/rust,robertg/rust,mitsuhiko/rust,servo/rust,sae-bom/rust,erickt/rust,ruud-v-a/rust,seanrivera/rust,pczarn/rust,AerialX/rust,pczarn/rust,fabricedesre/rust,dwillmer/rust,jroesch/rust,Ryman/rust,dwillmer/rust,kwantam/rust,nwin/rust,pythonesque/rust,nham/rust,aneeshusa/rust,dinfuehr/rust,barosl/rust,kimroen/rust,cllns/rust,gifnksm/rust,jashank/rust,vhbit/rust,bombless/rust,fabricedesre/rust,aneeshusa/rust,SiegeLord/rust,mihneadb/rust,vhbit/rust,GBGamer/rust,nham/rust,nham/rust,philyoon/rust,nwin/rust,quornian/rust,vhbit/rust,pelmers/rust,sae-bom/rust,quornian/rust,emk/rust,krzysz00/rust,l0kod/rust,aneeshusa/rust,gifnksm/rust,pythonesque/rust,jashank/rust,0x73/rust,LeoTestard/rust,nham/rust,mdinger/rust,jashank/rust,richo/rust,servo/rust,zubron/rust,XMPPwocky/rust,TheNeikos/rust,gifnksm/rust,LeoTestard/rust,barosl/rust,gifnksm/rust,hauleth/rust,AerialX/rust-rt-minimal,dwillmer/rust,kimroen/rust,AerialX/rust,stepancheg/rust-ide-rust,AerialX/rust-rt-minimal