Changeset 6631


Ignore:
Timestamp:
2004-01-28T14:38:38+13:00 (20 years ago)
Author:
jmt12
Message:

Due to the lack of a 'perfect' pattern against which valid URLs match, I've decided to disable URL valiadation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/URLField.java

    r6622 r6631  
    1111    implements DocumentListener {
    1212
    13     //static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?(([a-zA-Z]([a-zA-Z]|[0-9]|[\\$\\-_\\&\\+]|[!\\*\"\'\\(\\)]|(%[0-9A-Fa-f][0-9A-Fa-f]))*(\\.[a-zA-Z]([a-zA-Z]|[0-9]|[\\$\\-_\\&\\+]|[!\\*\"\'\\(\\)]|(%[0-9A-Fa-f][0-9A-Fa-f]))*)*)|(([0-9])+\\.([0-9])+\\.([0-9])+\\.([0-9])+))(:([0-9])+)?(/([a-zA-Z]|[0-9]|[\\$\\-_\\.\\&\\+]|[!\\*\"\'\\(\\),]|(%[0-9A-Fa-f][0-9A-Fa-f]))*)*");
     13    static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?(([a-zA-Z]([a-zA-Z]|[0-9]|[\\$\\-_\\&\\+]|[!\\*\"\'\\(\\)]|(%[0-9A-Fa-f][0-9A-Fa-f]))*(\\.[a-zA-Z]([a-zA-Z]|[0-9]|[\\$\\-_\\&\\+]|[!\\*\"\'\\(\\)]|(%[0-9A-Fa-f][0-9A-Fa-f]))*)*)|(([0-9])+\\.([0-9])+\\.([0-9])+\\.([0-9])+))(:([0-9])+)?(/([a-zA-Z]|[0-9]|[\\$\\-_\\.\\&\\+]|[!\\*\"\'\\(\\),]|(%[0-9A-Fa-f][0-9A-Fa-f]))*)*");
    1414
    1515    // Crap RegEx that matches everything dammit
     
    1818    //static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?[a-zA-Z0-9-]*(\.[a-zA-Z0-9-])*");
    1919
    20     static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?[\\w]+(\\.[\\w]+)([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?");
     20    //static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?[\\w]+(\\.[\\w]+)([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?");
    2121
    2222    private Color background;
     
    7272
    7373    public boolean validateURL() {
    74     boolean result;
    75     String text = getText();
    76     Matcher m = URL_PATTERN.matcher(text);
    77     if(text.length() == 0 || m.matches()) {
    78         setBackground(background);
    79         setForeground(foreground);
    80         result = true;
    81     }
    82     else {
    83         setBackground(invalid_background);
    84         setForeground(invalid_foreground);
    85         result = false;
    86     }
    87     m = null;
    88     return result;
     74    return true;
     75//      boolean result;
     76//      String text = getText();
     77//      Matcher m = URL_PATTERN.matcher(text);
     78//      if(text.length() == 0 || m.matches()) {
     79//          setBackground(background);
     80//          setForeground(foreground);
     81//          result = true;
     82//      }
     83//      else {
     84//          setBackground(invalid_background);
     85//          setForeground(invalid_foreground);
     86//          result = false;
     87//      }
     88//      m = null;
     89//      System.err.println("Validating: " + text + " -> " + (result ? "GOOD" : "BAD"));
     90//      text = null;
     91//      return result;
    8992    }
    9093
Note: See TracChangeset for help on using the changeset viewer.