Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: cvs-plugin
    • Labels:
      None
    • Similar Issues:

      Description

      ProjectSet files support added in the 2.6 version of the CVS plugin parses incorrectly the psf file. The current regular expression has some shortcomings:

      • If the name of the server contains dots, (cvs.example.org, 192.168.0.24), the parsing fails.
      • If the port is not explicitly set, it also fails, since the colon after the hostname is mandatory, and the expression only acknowledges it before a port (:pserver:host:/cvsroot vs :pserver:host:2401/cvsroot)
      • The module remote name does not support nested folders, since it does not allow slashes (:pserver:host:/cvsroot,CORE/com.example.project,com.example.project)

      The following expression solves these problems while keeping the groups, so the rest of the code doesn't need changes:

      private static final Pattern PSF_PATTERN = Pattern.compile("<project reference=\"[^,]+,((:[a-z]+:)([a-z|A-Z|0-9|\\.]+)"
      			+ "(:([0-9]+)?)([/|a-z|A-Z|_|0-9]+)),(/|[A-Z|a-z|0-9|_|\\.]+),([A-Z|a-z|0-9|_|\\.]+)(,(.*?)){0,1}\"/>");
      

        Attachments

          Activity

          Hide
          mc1arke Michael Clarke added a comment -

          Thanks for the recommendation. I'll review your regexp and apply it to the code. I'm planning on performing a release of the plugin at some point this week and will ensure this issue is included in it.

          Show
          mc1arke Michael Clarke added a comment - Thanks for the recommendation. I'll review your regexp and apply it to the code. I'm planning on performing a release of the plugin at some point this week and will ensure this issue is included in it.
          Hide
          mc1arke Michael Clarke added a comment -

          A slight tweak to your regular expression based on the following rules:

          1. CVSRoot allows a colon before the path on the server without a port number being specified. I'm assuming projectset uses the same format.
          2. The slash in the module name could be repeated anywhere in the path so I've moved that to inside the repeated character selection.

          This gives the following regexp:

          private static final Pattern PSF_PATTERN = Pattern.compile("<project reference=\"[^,]+,((:[a-z]+:)([a-z|A-Z|0-9|\\.]+)" +
                      "(:([0-9]+)?)?([/|a-z|A-Z|_|0-9]+)),([/|A-Z|a-z|0-9|_|\\.]+),([A-Z|a-z|0-9|_|\\.]+)(,(.*?)){0,1}\"/>");
          

          Let me know if you disagree with my logic or this regexp doesn't work for you, in the meantime I'll apply this change to the code.

          Show
          mc1arke Michael Clarke added a comment - A slight tweak to your regular expression based on the following rules: 1. CVSRoot allows a colon before the path on the server without a port number being specified. I'm assuming projectset uses the same format. 2. The slash in the module name could be repeated anywhere in the path so I've moved that to inside the repeated character selection. This gives the following regexp: private static final Pattern PSF_PATTERN = Pattern.compile("<project reference=\"[^,]+,((:[a-z]+:)([a-z|A-Z|0-9|\\.]+)" + "(:([0-9]+)?)?([/|a-z|A-Z|_|0-9]+)),([/|A-Z|a-z|0-9|_|\\.]+),([A-Z|a-z|0-9|_|\\.]+)(,(.*?)){0,1}\"/>"); Let me know if you disagree with my logic or this regexp doesn't work for you, in the meantime I'll apply this change to the code.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Michael Clarke
          Path:
          src/main/java/hudson/scm/CvsProjectset.java
          http://jenkins-ci.org/commit/cvs-plugin/d413566ddba3090571fa98aea3177f36f47eddf5
          Log:
          [FIXED JENKINS-15525] Change projectset regular expression parser
          1. Support periods in hostname/IP Address of CVS Root
          2. Allow no port to be specified in CVS Root with colon still being present
          2. Allow slashes in remote module name

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Michael Clarke Path: src/main/java/hudson/scm/CvsProjectset.java http://jenkins-ci.org/commit/cvs-plugin/d413566ddba3090571fa98aea3177f36f47eddf5 Log: [FIXED JENKINS-15525] Change projectset regular expression parser 1. Support periods in hostname/IP Address of CVS Root 2. Allow no port to be specified in CVS Root with colon still being present 2. Allow slashes in remote module name
          Hide
          felix_velasco Félix velasco added a comment -

          Regarding your points:

          1. I thought that colon was mandatory, not optional. That's why I took it out of the optional part
          2. My bad, I put the slash in the wrong place (most embarrassingly, since I need that slash in the middle of the remote module name).

          However, I honestly believe regexp is way too complicated, error-prone and hard to maintain for this job. Just a couple of StringTokenizers, first using commas, then colons for the cvsroot, should be enough. Just my two cents.

          Anyway, the committed change works perfectly for my psfs. Thank you!

          Show
          felix_velasco Félix velasco added a comment - Regarding your points: 1. I thought that colon was mandatory, not optional. That's why I took it out of the optional part 2. My bad, I put the slash in the wrong place (most embarrassingly, since I need that slash in the middle of the remote module name). However, I honestly believe regexp is way too complicated, error-prone and hard to maintain for this job. Just a couple of StringTokenizers, first using commas, then colons for the cvsroot, should be enough. Just my two cents. Anyway, the committed change works perfectly for my psfs. Thank you!
          Hide
          ralf_eisele Ralf Eisele added a comment - - edited

          If the cvs module name contains a "-" then the regexp pattern fails. The following pattern corrects this:

          private static final Pattern PSF_PATTERN = Pattern.compile("<project reference=\"[^,]+,((:[a-z]+:)([a-z|A-Z|0-9|\\.]+)" +
                      "(:([0-9]+)?)?([/|a-z|A-Z|_|0-9]+)),([/|A-Z|a-z|0-9|_|\\-|\\.]+),([A-Z|a-z|0-9|_|\\-|\\.]+)(,(.*?)){0,1}\"/>");
          
          Show
          ralf_eisele Ralf Eisele added a comment - - edited If the cvs module name contains a "-" then the regexp pattern fails. The following pattern corrects this: private static final Pattern PSF_PATTERN = Pattern.compile( "<project reference=\" [^,]+,((:[a-z]+:)([a-z|A-Z|0-9|\\.]+)" + "(:([0-9]+)?)?([/|a-z|A-Z|_|0-9]+)),([/|A-Z|a-z|0-9|_|\\-|\\.]+),([A-Z|a-z|0-9|_|\\-|\\.]+)(,(.*?)){0,1}\" />");
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: mc1arke
          Path:
          src/main/java/hudson/scm/CvsProjectset.java
          http://jenkins-ci.org/commit/cvs-plugin/d2c7f2614f98b5814e4dfec5d5bc32ca81dcdeb4
          Log:
          [FIXED JENKINS-15525] Allow dashes in module names

          Add support for modules with dashes in their names for the projectset parse

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: mc1arke Path: src/main/java/hudson/scm/CvsProjectset.java http://jenkins-ci.org/commit/cvs-plugin/d2c7f2614f98b5814e4dfec5d5bc32ca81dcdeb4 Log: [FIXED JENKINS-15525] Allow dashes in module names Add support for modules with dashes in their names for the projectset parse
          Hide
          mc1arke Michael Clarke added a comment -

          The following fixes for this issue have been included in cvs-2.7:

          • [FIXED JENKINS-15525] Change projectset regular expression parser
            1. Support periods in hostname/IP Address of CVS Root
            2. Allow no port to be specified in CVS Root with colon still being present
            2. Allow slashes in remote module name

          Show
          mc1arke Michael Clarke added a comment - The following fixes for this issue have been included in cvs-2.7: [FIXED JENKINS-15525] Change projectset regular expression parser 1. Support periods in hostname/IP Address of CVS Root 2. Allow no port to be specified in CVS Root with colon still being present 2. Allow slashes in remote module name

            People

            • Assignee:
              mc1arke Michael Clarke
              Reporter:
              felix_velasco Félix velasco
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: