mode-csp.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ace.define("ace/mode/csp_highlight_rules",[], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var CspHighlightRules = function() {
  6. var keywordMapper = this.createKeywordMapper({
  7. "constant.language": "child-src|connect-src|default-src|font-src|frame-src|img-src|manifest-src|media-src|object-src"
  8. + "|script-src|style-src|worker-src|base-uri|plugin-types|sandbox|disown-opener|form-action|frame-ancestors|report-uri"
  9. + "|report-to|upgrade-insecure-requests|block-all-mixed-content|require-sri-for|reflected-xss|referrer|policy-uri",
  10. "variable": "'none'|'self'|'unsafe-inline'|'unsafe-eval'|'strict-dynamic'|'unsafe-hashed-attributes'"
  11. }, "identifier", true);
  12. this.$rules = {
  13. start: [{
  14. token: "string.link",
  15. regex: /https?:[^;\s]*/
  16. }, {
  17. token: "operator.punctuation",
  18. regex: /;/
  19. }, {
  20. token: keywordMapper,
  21. regex: /[^\s;]+/
  22. }]
  23. };
  24. };
  25. oop.inherits(CspHighlightRules, TextHighlightRules);
  26. exports.CspHighlightRules = CspHighlightRules;
  27. });
  28. ace.define("ace/mode/csp",[], function(require, exports, module) {
  29. "use strict";
  30. var TextMode = require("./text").Mode;
  31. var CspHighlightRules = require("./csp_highlight_rules").CspHighlightRules;
  32. var oop = require("../lib/oop");
  33. var Mode = function() {
  34. this.HighlightRules = CspHighlightRules;
  35. };
  36. oop.inherits(Mode, TextMode);
  37. (function() {
  38. this.$id = "ace/mode/csp";
  39. }).call(Mode.prototype);
  40. exports.Mode = Mode;
  41. });
  42. (function() {
  43. ace.require(["ace/mode/csp"], function(m) {
  44. if (typeof module == "object" && typeof exports == "object" && module) {
  45. module.exports = m;
  46. }
  47. });
  48. })();