Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-74120

[managed-scripts] Extract inline script block in org/jenkinsci/plugins/managedscripts/ScriptConfig/edit-config.jelly

XMLWordPrintable

      Problem

      == Inline Script Block
      Line: 58
      ----
      <script>
                  document.onreadystatechange = function(){
                      // editor.on seems to require newer codemirror version
                      // var pending;
                      // editor.on("change", function() {
                      //      clearTimeout(pending);
                      //      pending = setTimeout(update, 400);
                      //  });
                      function looksLike(code) {
                          var firstline = code.split('\n')[0];
                          if(firstline.indexOf('#!') == 0){
                              var shellpattern = /bin\/[\w]{0,2}sh/;
                              var shellpatternwin = /[\w]{0,2}sh\.exe/;
                              if(firstline.indexOf('python') > -1){
                                  return "python";
                              // perl requires stapler-adjunct-codemirror > 1.3
                              }else if(firstline.indexOf('perl') > -1){
                                  return "perl";
                              }else if(shellpattern.exec(firstline) || shellpatternwin.exec(firstline)){
                                  return "shell";
                              }
                          }
                      }
                      function update() {
                          editor.setOption("mode", looksLike(editor.getValue()));
                      }
                      update();
                  };
              </script>
      ----
      

      Solution

      https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks

            shlomo_dahan Shlomo
            basil Basil Crow
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: