Home / Function/ String() — netty Function Reference

String() — netty Function Reference

Architecture documentation for the String() function in HttpStaticFileServerHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  0e1a5727_14de_fa86_3484_ed704c82ce5d["String()"]
  02ca82d7_508c_aabe_bb4d_dd1603c38b01["HttpStaticFileServerHandler"]
  0e1a5727_14de_fa86_3484_ed704c82ce5d -->|defined in| 02ca82d7_508c_aabe_bb4d_dd1603c38b01
  style 0e1a5727_14de_fa86_3484_ed704c82ce5d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java lines 244–270

    private static String sanitizeUri(String uri) {
        // Decode the path.
        try {
            uri = URLDecoder.decode(uri, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new Error("Invalid URI: " + uri, e);
        }

        if (uri.isEmpty() || uri.charAt(0) != '/') {
            return null;
        }

        // Convert file separators.
        uri = uri.replace('/', File.separatorChar);

        // Simplistic dumb security check.
        // You will have to do something serious in the production environment.
        if (uri.contains(File.separator + '.') ||
                uri.contains('.' + File.separator) ||
                uri.charAt(0) == '.' || uri.charAt(uri.length() - 1) == '.' ||
                INSECURE_URI.matcher(uri).matches()) {
            return null;
        }

        // Convert to absolute path.
        return SystemPropertyUtil.get("user.dir") + File.separator + uri;
    }

Domain

Subdomains

Frequently Asked Questions

What does String() do?
String() is a function in the netty codebase, defined in example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java.
Where is String() defined?
String() is defined in example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java at line 244.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free