Esempio n. 1
0
	def testUnderEscape(self):
		for x in range(0, 128):
			unescaped = chr(x)
			escaped = escaping.underscore_escape(unescaped)
			assert safe.match(escaped), escaped
			self.assertEqual(unescaped, escaping.ununderscore_escape(escaped))

		self.assertEqual("_2e_", escaping.underscore_escape("."))
		self.assertEqual("_2e_.", escaping.underscore_escape(".."))
Esempio n. 2
0
	def testUnderEscape(self):
		for x in range(0, 128):
			unescaped = chr(x)
			escaped = escaping.underscore_escape(unescaped)
			assert safe.match(escaped), escaped
			self.assertEqual(unescaped, escaping.ununderscore_escape(escaped))

		self.assertEqual("_2e_", escaping.underscore_escape("."))
		self.assertEqual("_2e_.", escaping.underscore_escape(".."))
Esempio n. 3
0
def escape_interface_uri(uri):
	"""Convert an interface URI to a list of path components.
	e.g. "http://example.com/foo.xml" becomes ["http", "example.com", "foo.xml"], while
	"file:///root/feed.xml" becomes ["file", "root__feed.xml"]
	The number of components is determined by the scheme (three for http, two for file).
	Uses L{support.escaping.underscore_escape} to escape each component.
	"""
	if uri.startswith('http://') or uri.startswith('https://'):
		scheme, rest = uri.split('://', 1)
		parts = rest.split('/', 1)
	else:
		assert os.path.isabs(uri), uri
		scheme = 'file'
		parts = [uri[1:]]
	
	return [scheme] + [escaping.underscore_escape(part) for part in parts]
Esempio n. 4
0
		def check(str):
			self.assertEqual(str, model.unescape(model.escape(str)))
			self.assertEqual(str, model.unescape(model._pretty_escape(str)))
			self.assertEqual(str,
				escaping.ununderscore_escape(escaping.underscore_escape(str)))
Esempio n. 5
0
		def check(str):
			self.assertEqual(str, model.unescape(model.escape(str)))
			self.assertEqual(str, model.unescape(model._pretty_escape(str)))
			self.assertEqual(str,
				escaping.ununderscore_escape(escaping.underscore_escape(str)))