file.php 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Validates file as defined by RFC 1630 and RFC 1738.
  4. */
  5. class HTMLPurifier_URIScheme_file extends HTMLPurifier_URIScheme {
  6. // Generally file:// URLs are not accessible from most
  7. // machines, so placing them as an img src is incorrect.
  8. public $browsable = false;
  9. // Basically the *only* URI scheme for which this is true, since
  10. // accessing files on the local machine is very common. In fact,
  11. // browsers on some operating systems don't understand the
  12. // authority, though I hear it is used on Windows to refer to
  13. // network shares.
  14. public $may_omit_host = true;
  15. public function doValidate(&$uri, $config, $context) {
  16. // Authentication method is not supported
  17. $uri->userinfo = null;
  18. // file:// makes no provisions for accessing the resource
  19. $uri->port = null;
  20. // While it seems to work on Firefox, the querystring has
  21. // no possible effect and is thus stripped.
  22. $uri->query = null;
  23. return true;
  24. }
  25. }
  26. // vim: et sw=4 sts=4