src/main/kotlin/de/uapcore/lightpit/AbstractServlet.kt

changeset 358
e46bef1bdddd
parent 357
8509308fbbe9
equal deleted inserted replaced
357:8509308fbbe9 358:e46bef1bdddd
92 logger.trace("invoke {0}", method) 92 logger.trace("invoke {0}", method)
93 method(HttpRequest(req, resp, params), dao) 93 method(HttpRequest(req, resp, params), dao)
94 } 94 }
95 95
96 private fun sanitizedRequestPath(req: HttpServletRequest) = req.pathInfo ?: "/" 96 private fun sanitizedRequestPath(req: HttpServletRequest) = req.pathInfo ?: "/"
97
98 protected fun sanitizeJson(str: String): String {
99 var result = "\""
100 for (i in str.indices) {
101 when (val c = str[i]) {
102 '\\', '"', '/' -> result += "\\$c"
103 '\t' -> result += "\\t"
104 '\n' -> result += "\\n"
105 '\r' -> result += "\\r"
106 else -> if (c < ' ' || (c in '\u0080'..'\u00bf') || (c in '\u2000'..'\u20ff')) {
107 result += "\\u%04x".format(c.code)
108 } else {
109 result += c
110 }
111 }
112 }
113 return result + "\""
114 }
97 115
98 private fun doProcess( 116 private fun doProcess(
99 req: HttpServletRequest, 117 req: HttpServletRequest,
100 resp: HttpServletResponse, 118 resp: HttpServletResponse,
101 mappings: Map<PathPattern, MappingMethod> 119 mappings: Map<PathPattern, MappingMethod>

mercurial