kelvint 2005/01/04 07:38:49 Modified: contributions/javascript/queryValidator luceneQueryValidator.js Log: Escapes the / character for FireFox 1.0. Revision Changes Path 1.10 +9 -9 jakarta-lucene-sandbox/contributions/javascript/queryValidator/luceneQueryValidator.js Index: luceneQueryValidator.js =================================================================== RCS file: /home/cvs/jakarta-lucene-sandbox/contributions/javascript/queryValidator/luceneQueryValidator.js,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- luceneQueryValidator.js 17 May 2004 11:53:59 -0000 1.9 +++ luceneQueryValidator.js 4 Jan 2005 15:38:49 -0000 1.10 @@ -103,7 +103,7 @@ function checkAllowedCharacters(query) { - matches = query.match(/[^a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/$%'= ]/); + matches = query.match(/[^a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/$%'= ]/); if(matches != null && matches.length > 0) { if(alertUser) alert("Invalid search query! The allowed characters are a-z A-Z 0-9. _ + - : () \" & * ? | ! {} [ ] ^ ~ \\ @ = # % $ ' /. Please try again.") @@ -129,7 +129,7 @@ matches = query.match(/[&]{2}/); if(matches != null && matches.length > 0) { - matches = query.match(/^([a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/$%'=]+( && )?[a-zA-Z0-9_+\-:.()\"*?|[EMAIL PROTECTED]/$%'=]+[ ]*)+$/); // note missing & in pattern + matches = query.match(/^([a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/$%'=]+( && )?[a-zA-Z0-9_+\-:.()\"*?|[EMAIL PROTECTED]/$%'=]+[ ]*)+$/); // note missing & in pattern if(matches == null) { if(alertUser) alert("Invalid search query! Queries containing the special characters && must be in the form: term1 && term2. Please try again.") @@ -141,7 +141,7 @@ function checkCaret(query) { - //matches = query.match(/^[^\^]*$|^([a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/]+(\^[\d]+)?[ ]*)+$/); // note missing ^ in pattern + //matches = query.match(/^[^\^]*$|^([a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/]+(\^[\d]+)?[ ]*)+$/); // note missing ^ in pattern matches = query.match(/[^\\]\^([^\s]*[^0-9.]+)|[^\\]\^$/); if(matches != null) { @@ -153,7 +153,7 @@ function checkSquiggle(query) { - //matches = query.match(/^[^~]*$|^([a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/]+(~[\d.]+|[^\\]\\~)?[ ]*)+$/); // note missing ~ in pattern + //matches = query.match(/^[^~]*$|^([a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/]+(~[\d.]+|[^\\]\\~)?[ ]*)+$/); // note missing ~ in pattern matches = query.match(/[^\\]~[^\s]*[^0-9\s]+/); if(matches != null) { @@ -167,7 +167,7 @@ { // foo! is not a query, but !foo is. hmmmm... // NB: doesn't handle term1 ! term2 ! term3 or term1 !term2 - matches = query.match(/^[^!]*$|^([a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/$%'=]+( ! )?[a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/$%'=]+[ ]*)+$/); + matches = query.match(/^[^!]*$|^([a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/$%'=]+( ! )?[a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/$%'=]+[ ]*)+$/); if(matches == null || matches.length == 0) { if(alertUser) alert("Invalid search query! Queries containing the special character ! must be in the form: term1 ! term2. Please try again.") @@ -180,7 +180,7 @@ function checkQuestionMark(query) { - matches = query.match(/^(\?)|([^a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/$%'=]\?+)/); + matches = query.match(/^(\?)|([^a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/$%'=]\?+)/); if(matches != null && matches.length > 0) { if(alertUser) alert("Invalid search query! The question mark (?) character must be preceded by at least one alphabet or number. Please try again.") @@ -226,7 +226,7 @@ function checkPlusMinus(query) { - matches = query.match(/^[^\n+\-]*$|^([+-]?[a-zA-Z0-9_:.()\"*?&|[EMAIL PROTECTED]/$%'=]+[ ]?)+$/); + matches = query.match(/^[^\n+\-]*$|^([+-]?[a-zA-Z0-9_:.()\"*?&|[EMAIL PROTECTED]/$%'=]+[ ]?)+$/); if(matches == null || matches.length == 0) { if(alertUser) alert("Invalid search query! '+' and '-' modifiers must be followed by at least one alphabet or number. Please try again.") @@ -240,7 +240,7 @@ matches = query.match(/AND|OR|NOT/); if(matches != null && matches.length > 0) { - matches = query.match(/^([a-zA-Z0-9_+\-:.()\"*?&|!{}\[\]\^~\\@/#$%'=]+\s*((AND )|(OR )|(AND NOT )|(NOT ))?[a-zA-Z0-9_+\-:.()\"*?&|!{}\[\]\^~\\@/#$%'=]+[ ]*)+$/); + matches = query.match(/^([a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/#$%'=]+\s*((AND )|(OR )|(AND NOT )|(NOT ))?[a-zA-Z0-9_+\-:.()\"*?&|[EMAIL PROTECTED]/#$%'=]+[ ]*)+$/); if(matches == null || matches.length == 0) { if(alertUser) alert("Invalid search query! Queries containing AND/OR/NOT must be in the form: term1 AND|OR|NOT|AND NOT term2 Please try again.")
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]