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

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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: core
    • Labels:
      None
    • Environment:
      Affects Chrome and Internet Explorer. Works fine in Firefox.

      Hudson Version 1.385
    • Similar Issues:
      Show 5 results

      Description

      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.

        Attachments

          Issue Links

            Activity

            mrobinet mrobinet created issue -
            Hide
            mrobinet mrobinet added a comment -

            Similar issues.

            Show
            mrobinet mrobinet added a comment - Similar issues.
            mrobinet mrobinet made changes -
            Field Original Value New Value
            Link This issue is related to JENKINS-6542 [ JENKINS-6542 ]
            mrobinet mrobinet made changes -
            Link This issue is related to JENKINS-6756 [ JENKINS-6756 ]
            Hide
            mrobinet 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.

            Show
            mrobinet 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.
            mindless Alan Harder made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            Hide
            scm_issue_link 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 '

            Show
            scm_issue_link 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 '
            scm_issue_link SCM/JIRA link daemon made changes -
            Status In Progress [ 3 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            Hide
            mindless Alan Harder added a comment -

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

            Show
            mindless Alan Harder added a comment - Thanks! I fixed that one, and found a couple other similar cases in jelly files for username with '
            Hide
            dogfood 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
            Show
            dogfood 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

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: