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

Apostrophe in view name causes the LOADING mask to never go away

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • None
    • Affects Chrome and Internet Explorer. Works fine in Firefox.

      Hudson Version 1.385

      Steps to reproduce:
      1. Create a view with an apostrophe in the name. (Make sure it is not the default view.)
      2. Add a job to this view
      3. Configure the job using Chrome or IE web browser.

      You'll notice the loading mask never disappears, despite the page fully loading. If the view is the default view, then it works just fine.

      Here is the JS error captured in Chrome:
      Uncaught SyntaxError: Unexpected identifier
      e.targetUrl hudson-behavior.js:338
      registerValidator hudson-behavior.js:343
      Object.extend._each prototype.js:676
      (anonymous function) behavior.js:61
      Object.extend._each prototype.js:676
      Behaviour.applySubtree behavior.js:58
      Behaviour.apply behavior.js:54
      (anonymous function) behavior.js:49

      Here is the error in IE:
      User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; MS-RTC LM 8; MS-RTC EA 2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
      Timestamp: Mon, 14 Feb 2011 16:33:23 UTC

      Message: Expected ';'
      Line: 338
      Char: 9
      Code: 0
      URI: http://ah-bart:2100/hudson/static/2e8191e3/scripts/hudson-behavior.js

      Assigning to Alan Harder due to his familiarity on similar issues.

          [JENKINS-8789] Apostrophe in view name causes the LOADING mask to never go away

          mrobinet added a comment -

          Similar issues.

          mrobinet added a comment - Similar issues.

          mrobinet added a comment -
          hudson.model.Descriptor.java
          private String getCurrentDescriptorByNameUrl() {
              StaplerRequest req = Stapler.getCurrentRequest();
              Ancestor a = req.findAncestor(DescriptorByNameOwner.class);
              return a.getUrl();
          }
          
          /**
           * If the field "xyz" of a {@link Describable} has the corresponding "doCheckXyz" method,
           * return the form-field validation string. Otherwise null.
           * <p>
           * This method is used to hook up the form validation method to the corresponding HTML input element.
           */
          public String getCheckUrl(String fieldName) {
             String method = checkMethods.get(fieldName);
             if(method==null) {
                 method = calcCheckUrl(fieldName);
                 checkMethods.put(fieldName,method);
             }
          
              if (method.equals(NONE)) // == would do, but it makes IDE flag a warning
                  return null;
          
              // put this under the right contextual umbrella.
              // a is always non-null because we already have Hudson as the sentinel
              return singleQuote(getCurrentDescriptorByNameUrl()+'/')+'+'+method;
          }
          

          Problem seems to be coming from the last line of getCheckUrl(String). The url returned from getCurrentDescriptorByNameUrl() contains the view name, which can contain a ', so when it is wrapped in single-quotes JavaScript errors result. I'm not sure how Firefox is fine with this, or what the proper solution is.

          mrobinet added a comment - hudson.model.Descriptor.java private String getCurrentDescriptorByNameUrl() { StaplerRequest req = Stapler.getCurrentRequest(); Ancestor a = req.findAncestor(DescriptorByNameOwner.class); return a.getUrl(); } /** * If the field "xyz" of a {@link Describable} has the corresponding "doCheckXyz" method, * return the form-field validation string. Otherwise null . * <p> * This method is used to hook up the form validation method to the corresponding HTML input element. */ public String getCheckUrl( String fieldName) { String method = checkMethods.get(fieldName); if (method== null ) { method = calcCheckUrl(fieldName); checkMethods.put(fieldName,method); } if (method.equals(NONE)) // == would do , but it makes IDE flag a warning return null ; // put this under the right contextual umbrella. // a is always non- null because we already have Hudson as the sentinel return singleQuote(getCurrentDescriptorByNameUrl()+ '/' )+ '+' +method; } Problem seems to be coming from the last line of getCheckUrl(String). The url returned from getCurrentDescriptorByNameUrl() contains the view name, which can contain a ', so when it is wrapped in single-quotes JavaScript errors result. I'm not sure how Firefox is fine with this, or what the proper solution is.

          Code changed in jenkins
          User: alanharder
          Path:
          changelog.html
          core/src/main/java/hudson/model/Descriptor.java
          core/src/main/resources/hudson/model/MyViewsProperty/config.jelly
          core/src/main/resources/hudson/model/MyViewsProperty/newView.jelly
          core/src/main/resources/hudson/model/ProxyView/configure-entries.jelly
          http://jenkins-ci.org/commit/core/e1c2c970c96fa30bb1f2724ec112f2b21f9814c5
          Log:
          [FIXED JENKINS-8789] Use jsStringEscape in a few places when contructing checkUrl,
          as this content later gets eval'ed. Javascript errors could occur when view names
          or user names contained '

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: alanharder Path: changelog.html core/src/main/java/hudson/model/Descriptor.java core/src/main/resources/hudson/model/MyViewsProperty/config.jelly core/src/main/resources/hudson/model/MyViewsProperty/newView.jelly core/src/main/resources/hudson/model/ProxyView/configure-entries.jelly http://jenkins-ci.org/commit/core/e1c2c970c96fa30bb1f2724ec112f2b21f9814c5 Log: [FIXED JENKINS-8789] Use jsStringEscape in a few places when contructing checkUrl, as this content later gets eval'ed. Javascript errors could occur when view names or user names contained '

          Alan Harder added a comment -

          Thanks! I fixed that one, and found a couple other similar cases in jelly files for username with '

          Alan Harder added a comment - Thanks! I fixed that one, and found a couple other similar cases in jelly files for username with '

          dogfood added a comment -

          Integrated in jenkins_main_trunk #514
          [FIXED JENKINS-8789] Use jsStringEscape in a few places when contructing checkUrl,

          alanharder :
          Files :

          • core/src/main/java/hudson/model/Descriptor.java
          • changelog.html
          • core/src/main/resources/hudson/model/MyViewsProperty/config.jelly
          • core/src/main/resources/hudson/model/ProxyView/configure-entries.jelly
          • core/src/main/resources/hudson/model/MyViewsProperty/newView.jelly

          dogfood added a comment - Integrated in jenkins_main_trunk #514 [FIXED JENKINS-8789] Use jsStringEscape in a few places when contructing checkUrl, alanharder : Files : core/src/main/java/hudson/model/Descriptor.java changelog.html core/src/main/resources/hudson/model/MyViewsProperty/config.jelly core/src/main/resources/hudson/model/ProxyView/configure-entries.jelly core/src/main/resources/hudson/model/MyViewsProperty/newView.jelly

            mindless Alan Harder
            mrobinet mrobinet
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: