OSDN Git Service

Uri matching looser.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Thu, 14 Sep 2006 03:12:05 +0000 (12:12 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Fri, 15 Sep 2006 00:13:25 +0000 (09:13 +0900)
src/FukuiNoNamari/BbsType/bbs_type_2ch.py
src/FukuiNoNamari/BbsType/bbs_type_jbbs.py
src/FukuiNoNamari/BbsType/bbs_type_other.py
src/FukuiNoNamari/BbsType/bbs_type_yy.py

index d9916a0..88f9c5a 100644 (file)
@@ -24,7 +24,7 @@ from bbs_type_base import BaseType
 # default name for morningcoffee
 moco_name = u'\u540d\u7121\u3057\u52df\u96c6\u4e2d\u3002\u3002\u3002'
 
-_base_reg_expr = re.compile("http://(?P<host>[^./]+\.2ch\.net)/(?P<board>[^/]+)/$")
+_base_reg_expr = re.compile("http://(?P<host>[^./]+\.2ch\.net)/(?P<board>[^/]+)(?:/[^/]*){0,1}$")
 _cgi_reg_expr = re.compile("http://(?P<host>[^./]+\.2ch\.net)/test/read.cgi/(?P<board>[^/]+)/(?P<thread>[^/]+)/.*")
 
 
index bc0252e..53841ec 100644 (file)
@@ -22,7 +22,7 @@ import time
 from bbs_type_exception import BbsTypeError
 from bbs_type_base import BaseType
 
-_base_reg_expr = re.compile("http://(?P<host>jbbs\.livedoor\.jp)/(?P<board>(?P<brd_dir>[^/]+)/(?P<brd_bbs>[^/]+))/$")
+_base_reg_expr = re.compile("http://(?P<host>jbbs\.livedoor\.jp)/(?P<board>(?P<brd_dir>[^/]+)/(?P<brd_bbs>[^/]+))(?:/[^/]*){0,1}$")
 _cgi_reg_expr = re.compile("http://(?P<host>jbbs\.livedoor\.jp)/bbs/read\.cgi/(?P<board>(?P<brd_dir>[^/]+)/(?P<brd_bbs>[^/]+))/(?P<thread>[^/]+)/.*")
 subject_reg_expr = re.compile("(?P<id>.*)\.cgi,(?P<title>.*)\((?P<res>\d*)\)")
 dat_reg_expr = re.compile("(?P<num>\d+)<>(?P<name>.*)<>(?P<mail>.*)<>(?P<date>.*)<>(?P<msg>.*)<>(?P<title>.*)<>(?P<id>.*)")
index f821505..0725adc 100644 (file)
@@ -31,7 +31,7 @@ try:
 except IOError:
     traceback.print_exc()
 
-_board_reg_expr = re.compile("http://(?P<host>.+)/(?P<board>[^/]+)/$")
+_board_reg_expr = re.compile("http://(?P<host>.+)/(?P<board>[^/]+)(?:/[^/]*){0,1}$")
 
 
 class TypeOther(BaseType):
@@ -39,12 +39,27 @@ class TypeOther(BaseType):
     _board_reg = _board_reg_expr
 
     def _parse_uri(self, uri):
+
+        def uri_base_match(uri, iru):
+            iru = iru.rstrip("/")
+            if uri.startswith(iru):
+                uri = uri[len(iru):]
+                if not uri:
+                    return True
+                elif uri[0] == "/":
+                    uri = uri[1:]
+                    if not uri:
+                        return True
+                    elif uri.find("/") == -1:
+                        return True
+            return False
+
         for iru in _whitelist:
             match = self._board_reg.match(iru)
             if match:
                 host = match.group("host")
                 board = match.group("board")
-                if uri == iru:
+                if uri_base_match(uri, "http://%s/%s" % (host, board)):
                     self.host = host
                     self.board = board
                     return
index 68f3aa5..f2e8861 100644 (file)
@@ -19,7 +19,7 @@ import re
 
 from bbs_type_2ch import BaseType
 
-_base_reg_expr = re.compile("http://(?P<host>yy\d{2}\.(?:kakiko\.com|60\.kg))/(?P<board>[^/]+)/$")
+_base_reg_expr = re.compile("http://(?P<host>yy\d{2}\.(?:kakiko\.com|60\.kg))/(?P<board>[^/]+)(?:/[^/]*){0,1}$")
 _cgi_reg_expr = re.compile("http://(?P<host>yy\d{2}\.(?:kakiko\.com|60\.kg))/test/read.cgi/(?P<board>[^/]+)/(?P<thread>[^/]+)/.*")