Permalink
Browse files

UNICODE DAMMIT! matching unicode in URL patterns.

  • Loading branch information...
toyg committed Jul 18, 2013
1 parent 6b86a40 commit 9ec84e94392c333f2647aba20bf00c7350e64357
Showing with 6 additions and 5 deletions.
  1. +3 −2 web/application.py
  2. +3 −3 web/utils.py
View
@@ -2,6 +2,7 @@
Web application
(from web.py)
"""
from re import UNICODE
import webapi as web
import webapi, wsgi, utils
import debugerror
@@ -476,7 +477,7 @@ def _match(self, mapping, value):
elif isinstance(what, basestring):
what, result = utils.re_subm('^' + pat + '$', what, value)
else:
result = utils.re_compile('^' + pat + '$').match(value)
result = utils.re_compile('^' + pat + '$').match(value, UNICODE)
if result: # it's a match
return what, [x for x in result.groups()]
@@ -588,7 +589,7 @@ def _match(self, mapping, value):
if isinstance(what, basestring):
what, result = utils.re_subm('^' + pat + '$', what, value)
else:
result = utils.re_compile('^' + pat + '$').match(value)
result = utils.re_compile('^' + pat + '$',UNICODE).match(value)
if result: # it's a match
return what, [x for x in result.groups()]
View
@@ -31,7 +31,7 @@
]
import re, sys, time, threading, itertools, traceback, os
from re import UNICODE
try:
import subprocess
except ImportError:
@@ -528,7 +528,7 @@ def re_subm(pat, repl, string):
>>> m.groups()
('oooooo',)
"""
compiled_pat = re_compile(pat)
compiled_pat = re_compile(pat,UNICODE)
proxy = _re_subm_proxy()
compiled_pat.sub(proxy.__call__, string)
return compiled_pat.sub(repl, string), proxy.match
@@ -1324,7 +1324,7 @@ def to36(q):
return "".join(converted) or '0'
r_url = re_compile('(?<!\()(http://(\S+))')
r_url = re_compile('(?<!\()(http://(\S+))', UNICODE)
def safemarkdown(text):
"""
Converts text to HTML following the rules of Markdown, but blocking any

0 comments on commit 9ec84e9

Please sign in to comment.