Posted to tcl by gwlester at Fri Jun 16 20:27:00 GMT 2017view raw

  1. ##
  2. ## What would be a value of srvurl that would give the "Illegal encoding character usage..."
  3. ## error?
  4. ##
  5. # Check for validity according to RFC 3986, Appendix A
  6. set validityRE {(?xi)
  7. ^
  8. # Path part (already must start with / character)
  9. (?: [-\w.~!$&'()*+,;=:@/] | %[0-9a-f][0-9a-f] )*
  10. # Query part (optional, permits ? characters)
  11. (?: \? (?: [-\w.~!$&'()*+,;=:@/?] | %[0-9a-f][0-9a-f] )* )?
  12. $
  13. }
  14. if {$state(-strict) && ![regexp -- $validityRE $srvurl]} {
  15. unset $token
  16. # Provide a better error message in this error case
  17. if {[regexp {(?i)%(?![0-9a-f][0-9a-f])..} $srvurl bad]} {
  18. return -code error \
  19. "Illegal encoding character usage \"$bad\" in URL path"
  20. }
  21. return -code error "Illegal characters in URL path"
  22. }
  23.