Update of /cvsroot/mahogany/M/src/util
In directory usw-pr-cvs1:/tmp/cvs-serv29963/src/util

Modified Files:
        matchurl.cpp 
Log Message:
- Definition of which chars can be part of an URL taken from RFC2396
- Avoid 'unwrapping' two URLs on two different lines.

Index: matchurl.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/util/matchurl.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -b -u -2 -r1.10 -r1.11
--- matchurl.cpp        29 Apr 2002 08:41:35 -0000      1.10
+++ matchurl.cpp        30 Apr 2002 13:24:03 -0000      1.11
@@ -362,11 +362,22 @@
 }
 
+/// checks a character to be a 'mark' as from RFC2396
+inline bool IsURLMark(char c)
+{
+   return c == '-' || c == '_' || c == '.' || c == '!' || c == '~' || 
+          c == '*' || c == '\'' || c == '(' || c == ')';
+}
+
+/// checks a character to be 'reserved' as from RFC2396
+inline bool IsURLReserved(char c)
+{
+   return c == ';' || c == '/' || c == '?' || c == ':' || c == '@' || 
+          c == '&' || c == '=' || c == '+' || c == '$' || c == ',';
+}
+
 /// checks a character to be a valid part of an URL
 inline bool IsURLChar(char c)
 {
-   // this is bogus, of course... we basicly assume that anything at all can be
-   // an URL except for '>' which, together with '<' is often used for
-   // delimiting the URLs
-   return IsAlnum(c) || !(iscntrl(c) || isspace(c) || c == '>' || c == '*');
+   return IsAlnum(c) || IsURLMark(c) || IsURLReserved(c) || c == '%';
 }
 
@@ -484,4 +495,14 @@
             break;
          }
+
+         // Check that the beginning of next line is not the start of
+         // another URL. Note that '@' alone is recognized as the beginning
+         // of an URL: here it should not be the case.
+         int nextlen = 0;
+         int nextpos = scan(p+2, nextlen);
+         if ( nextlen && nextpos == 0 && p[2] != '@')
+            // The start of the next line being the start of an URL on its own,
+            // do not join the two.
+            break;
 
          // it might be a wrapped URL but it might be not: it seems like we


_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to