url_sanitizer.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * @license
  3. * SPDX-License-Identifier: Apache-2.0
  4. */
  5. /**
  6. * @fileoverview Provides functions to enforce the SafeUrl contract at the sink
  7. * level.
  8. */
  9. import '../environment/dev';
  10. /**
  11. * Checks that the URL scheme is not javascript.
  12. * The URL parsing relies on the URL API in browsers that support it.
  13. * @param url The URL to sanitize for a SafeUrl sink.
  14. * @return undefined if url has a javascript: scheme, the original URL
  15. * otherwise.
  16. */
  17. export declare function sanitizeJavascriptUrl(url: string): string | undefined;
  18. /**
  19. * Type alias for URLs passed to DOM sink wrappers.
  20. */
  21. export declare type Url = string;
  22. /**
  23. * Adapter to sanitize string URLs in DOM sink wrappers.
  24. * @return undefined if the URL was sanitized.
  25. */
  26. export declare function unwrapUrlOrSanitize(url: Url): string | undefined;
  27. /**
  28. * Sanitizes a URL restrictively.
  29. * This sanitizer protects against XSS and potentially other uncommon and
  30. * undesirable schemes that an attacker could use for e.g. phishing (tel:,
  31. * callto: ssh: etc schemes). This sanitizer is primarily meant to be used by
  32. * the HTML sanitizer.
  33. */
  34. export declare function restrictivelySanitizeUrl(url: string): string;