Subversion Repositories DevTools

Rev

Rev 1339 | Rev 2362 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1339 Rev 1372
Line 65... Line 65...
65
     if (restore) selObj.selectedIndex=0;
65
     if (restore) selObj.selectedIndex=0;
66
  }
66
  }
67
}
67
}
68
 
68
 
69
function MM_validateForm() { //v5.0
69
function MM_validateForm() { //v5.0
70
   var i,p,pl,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
70
   var ii,p,pl,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
71
   var REresults;
71
   var REresults;
72
   var pass,passc;
72
   var pass,passc;
73
 
73
 
74
 
-
 
75
 
-
 
76
   // Other general validations
74
   // Other general validations
77
   var cleanStrRE = /^[0-9a-z_\.\(\)\-]+$/i;
75
   var cleanStrRE = /^[0-9a-z_\.\(\)\-]+$/i;
78
   var pkgRE = /^[a-z][a-z0-9_-]*[a-z0-9]$/i;
76
   var pkgRE = /^[a-z][a-z0-9_-]*[a-z0-9]$/i;
79
   var versionRE = /^[0-9a-z_\.\(\)\-]+$/i;
77
   var versionRE = /^[0-9a-z_\.\(\)\-]+$/i;
80
   var versionNumberRE = /^\d+\.\d+\.\d+$/;
78
   var versionNumberRE = /^\d+\.\d+\.\d+$/;
Line 82... Line 80...
82
   var urlRE = "^https?://[a-z1-9]";
80
   var urlRE = "^https?://[a-z1-9]";
83
   //character range disallowed
81
   //character range disallowed
84
   var HTMLchr = /[\<\>\'\"]+/i;
82
   var HTMLchr = /[\<\>\'\"]+/i;
85
   var alphanumRE = /^[a-z0-9]+$/i;
83
   var alphanumRE = /^[a-z0-9]+$/i;
86
 
84
 
87
   for (i=0; i<(args.length-2); i+=3) {
85
   for (ii=0; ii<(args.length-2); ii+=3) {
88
      test=args[i+2];
86
      test=args[ii+2];
89
      val=MM_findObj(args[i]);
87
      val=MM_findObj(args[ii]);
90
 
88
 
91
      if (val) {
89
      if (val) {
92
         nm=args[i+1];
90
         nm=args[ii+1];
93
         val=val.value;
91
         val=val.value;
94
 
92
 
95
 
93
 
96
 
94
 
97
         if (val!="") {
95
         if (val!="") {
Line 115... Line 113...
115
               }
113
               }
116
            }
114
            }
117
 
115
 
118
            if (test.indexOf('isPackage')!=-1) {
116
            if (test.indexOf('isPackage')!=-1) {
119
               REresults = val.search(pkgRE);
117
               REresults = val.search(pkgRE);
120
               if (REresults < 0) errors += val += ' - '+nm+' is not valid. Valid characters are A-Z a-z 0-9 - _\n'
118
               if (REresults < 0) errors += val + ' - '+nm+' is not valid. Valid characters are A-Z a-z 0-9 - _\n'
121
                        + 'Names must start with a letter and cannot contain spaces or symbols other than - and _\n';
119
                        + 'Names must start with a letter and cannot contain spaces or symbols other than - and _\n';
122
            }
120
            }
123
 
121
 
124
            if (test.indexOf('isCleanStr')!=-1) {
122
            if (test.indexOf('isCleanStr')!=-1) {
125
               REresults = val.search(cleanStrRE);
123
               REresults = val.search(cleanStrRE);
126
               if (REresults < 0) errors += val += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
124
               if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
127
            }
125
            }
128
 
126
 
129
            if (test.indexOf('isVersionStr')!=-1) {
127
            if (test.indexOf('isVersionStr')!=-1) {
130
               REresults = val.search(versionRE);
128
               REresults = val.search(versionRE);
131
               if (REresults < 0) errors += val += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
129
               if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
132
            }
130
            }
133
 
131
 
134
            if (test.indexOf('isPatchVersionStr')!=-1) {
132
            if (test.indexOf('isPatchVersionStr')!=-1) {
135
               if ( !re_patch_ver_format.test(val) ) {
133
               if ( !re_patch_ver_format.test(val) ) {
136
                  errors += val += '- '+nm+' is not of form (integer).(integer).(integer).p(integer).(extension)\n';
134
                  errors += val + '- '+nm+' is not of form (integer).(integer).(integer).p(integer).(extension)\n';
137
               }
135
               }
138
            }
136
            }
139
 
137
 
140
            if (test.indexOf('isCCPath')!=-1) {
138
            if (test.indexOf('isCCPath')!=-1) {
141
               var CCPathRE = /^\\|\/[a-z]+[0-9a-z_\.\-\\\/ ]+$/i;
139
               var CCPathRE = /^\\|\/[a-z]+[0-9a-z_\.\-\\\/ ]+$/i;
142
 
140
 
143
               REresults = val.search(CCPathRE);
141
               REresults = val.search(CCPathRE);
144
               if (REresults < 0) errors += val += '- '+nm+' uses invalid character.\nAllowed characters are \\ / A-Z a-z 0-9 . - _ SPACE\nAnd the path must begin with \\ or /';
142
               if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are \\ / A-Z a-z 0-9 . - _ SPACE\nAnd the path must begin with \\ or /';
145
            }
143
            }
146
 
144
 
147
            if (test.indexOf('isCCLabel')!=-1) {
145
            if (test.indexOf('isCCLabel')!=-1) {
148
               var CCLabelRE = /^[0-9a-z_\.\-]+$/i;
146
               var CCLabelRE = /^[0-9a-z_\.\-]+$/i;
149
 
147
 
150
               REresults = val.search(CCLabelRE);
148
               REresults = val.search(CCLabelRE);
151
               if (REresults < 0) errors += val += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
149
               if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
152
            }
150
            }
153
 
151
 
154
            if (test.indexOf('isSVNTag')!=-1) {
152
            if (test.indexOf('isSVNTag')!=-1) {
155
                // Subversion Tag validation
153
                // Subversion Tag validation
156
                var SVNTagValidPeg = /^@?\d+$/;
154
                var SVNTagValidPeg = /^@?\d+$/;
157
                var SVNTagRE = /^[0-9a-z_\.\-]+$/i;
155
                var SVNTagRE = /^[0-9a-z_\.\-]+$/i;
158
                
156
                
159
               if ( val.search(SVNTagValidPeg) < 0) {
157
               if ( val.search(SVNTagValidPeg) < 0) {
160
                    val = val.replace (/@\d+$/,"");
-
 
161
 
158
 
-
 
159
                    var stripped;
-
 
160
                    stripped = val.replace (/@\d+$/,"");
162
               if (val.search(SVNTagRE) < 0) 
161
                    if (stripped.search(SVNTagRE) < 0)
163
                    errors += val += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
162
                        errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
-
 
163
               }
-
 
164
            }
-
 
165
 
-
 
166
            if (test.indexOf('isSVNPegTag')!=-1 && ! errors) {
-
 
167
                // Subversion Tag has peg - Must have done valid check first
-
 
168
                var SVNTagPegged = /@?\d+$/;
-
 
169
 
-
 
170
                if ( val.search(SVNTagPegged) < 0) {
-
 
171
                    errors += val + '- '+nm+' Must be pegged for Manually Versioned Package\n';
164
               }
172
               }
165
            }
173
            }
166
            
174
            
167
            if (test.indexOf('isSVNPath')!=-1) {
175
            if (test.indexOf('isSVNPath')!=-1) {
168
               // Subversion Base Path validation
176
               // Subversion Base Path validation
Line 172... Line 180...
172
               var SVNTagInValidSlash = /^.*\/\/.*$/i;
180
               var SVNTagInValidSlash = /^.*\/\/.*$/i;
173
               var SVNTagInValidTrunkAnywhereRE = /\/trunk\//i;
181
               var SVNTagInValidTrunkAnywhereRE = /\/trunk\//i;
174
               var SVNTagValidTagAnywhereRE = /^.*\/tags\/.*$/i;
182
               var SVNTagValidTagAnywhereRE = /^.*\/tags\/.*$/i;
175
 
183
 
176
               if (val.search(SVNTagValidCharsRE) < 0)
184
               if (val.search(SVNTagValidCharsRE) < 0)
177
                  errors += val += ' - '+nm+' uses invalid character. Allowed characters are / A-Z a-z 0-9 . - _\n';
185
                  errors += val + ' - '+nm+' uses invalid character. Allowed characters are / A-Z a-z 0-9 . - _\n';
178
               else if (val.search(SVNTagInValidSlashAtBOL) >= 0)
186
               else if (val.search(SVNTagInValidSlashAtBOL) >= 0)
179
                  errors += val += ' - '+nm+' begins with a /. This is not allowed.\n';
187
                  errors += val + ' - '+nm+' begins with a /. This is not allowed.\n';
180
               else if (val.search(SVNTagInValidSlashAtEOL) >= 0)
188
               else if (val.search(SVNTagInValidSlashAtEOL) >= 0)
181
                  errors += val += ' - '+nm+' ends with a /. This is not allowed.\n';
189
                  errors += val + ' - '+nm+' ends with a /. This is not allowed.\n';
182
               else if (val.search(SVNTagInValidSlash) >= 0)
190
               else if (val.search(SVNTagInValidSlash) >= 0)
183
                  errors += val += ' - '+nm+' uses //. This is not allowed.\n';
191
                  errors += val + ' - '+nm+' uses //. This is not allowed.\n';
184
               else if (val.search(SVNTagValidTagAnywhereRE) >= 0)
192
               else if (val.search(SVNTagValidTagAnywhereRE) >= 0)
185
                     errors += val += ' - '+nm+' contains /tags/. This is not allowed.\n';
193
                     errors += val + ' - '+nm+' contains /tags/. This is not allowed.\n';
186
               else if (val.search(SVNTagInValidTrunkAnywhereRE) >= 0)
194
               else if (val.search(SVNTagInValidTrunkAnywhereRE) >= 0)
187
                     errors += val += ' - '+nm+' contains /trunk/. This is not allowed.\n';
195
                     errors += val + ' - '+nm+' contains /trunk/. This is not allowed.\n';
188
               else {
196
               else {
189
                        var bits = val.split("/");
197
                        var bits = val.split("/");
190
                        if ( bits.length < 4 )
198
                        if ( bits.length < 4 )
191
                            errors += val += ' - Must contain at least 4 path items.\n';
199
                            errors += val + ' - Must contain at least 4 path items.\n';
192
                        
200
                        
193
                        var ttbcount = 0;
201
                        var ttbcount = 0;
-
 
202
                        var i
194
                        for (i=0; i < bits.length; i++ )
203
                        for (i=0; i < bits.length; i++ )
195
                        {
204
                        {
196
                            var el = bits[i];
205
                            var el = bits[i];
197
                            if ( el == 'tags') ttbcount++;
206
                            if ( el == 'tags') ttbcount++;
198
                            if ( el == 'trunk') ttbcount++;
207
                            if ( el == 'trunk') ttbcount++;
199
                            if ( el == 'branches') ttbcount++;
208
                            if ( el == 'branches') ttbcount++;
200
                        }
209
                        }
201
                        if ( ttbcount != 1 )
210
                        if ( ttbcount != 1 )
202
                            errors += val += ' - '+nm+' must contain exactly one of tags, trunk or branches. It contains '+ttbcount+'.\n';
211
                            errors += val + ' - '+nm+' must contain exactly one of tags, trunk or branches. It contains '+ttbcount+'.\n';
203
                          
212
                          
204
                        if ( bits.pop() == 'branches' )    
213
                        if ( bits.pop() == 'branches' )    
205
                            errors += val += ' - '+nm+' must not end in branches.\n';
214
                            errors += val + ' - '+nm+' must not end in branches.\n';
206
                        
215
                        
207
                     }
216
                     }
208
            }
217
            }
209
 
218
 
210
            if (test.indexOf('isVersionNumber')!=-1) {
219
            if (test.indexOf('isVersionNumber')!=-1) {
211
               REresults = val.search(versionNumberRE);
220
               REresults = val.search(versionNumberRE);
212
               if (REresults < 0) errors += val += ' - '+nm+' is formatted incorrectly.\nVersion number should be (major).(minor).(patch)(build)\ne.g. 1.0.2002\n';
221
               if (REresults < 0) errors += val + ' - '+nm+' is formatted incorrectly.\nVersion number should be (major).(minor).(patch)(build)\ne.g. 1.0.2002\n';
213
            }
222
            }
214
 
223
 
215
            if (test.indexOf('isURL')!=-1) {
224
            if (test.indexOf('isURL')!=-1) {
216
               REresults = val.match(urlRE);
225
               REresults = val.match(urlRE);
217
               if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';
226
               if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';