class_docstr: Standalone WSGI app that can serve files, etc.
class_docstr_tok: ["Standalone","WSGI","app","that","can","serve","files",",","etc","."]
docstr: Check path is safe (stays within current directory).
  
  This is for preventing directory-traversal attacks.
  
  Args:
    path: The path to check for safety.
  
  Returns:
    True if the given path stays within the project directory, and false
    if it would escape to a higher directory. E.g. _path_is_safe('index.html')
    returns true, but _path_is_safe('../../../etc/password') returns false.
docstr_tok: ["Check","path","is","safe","(","stays","within","current","directory",")",".","This","is","for","preventing","directory-traversal","attacks",".","Args",":","path",":","The","path","to","check","for","safety",".","Returns",":","True","if","the","given","path","stays","within","the","project","directory",",","and","false","if","it","would","escape","to","a","higher","directory",".","E.g",".","_path_is_safe","(","'index.html","'",")","returns","true",",","but","_path_is_safe","(","'","..","\/","..","\/","..","\/etc\/password","'",")","returns","false","."]
code: def _PathIsSafe(self, path):
      """Check path is safe (stays within current directory).
  
      This is for preventing directory-traversal attacks.
  
      Args:
        path: The path to check for safety.
  
      Returns:
        True if the given path stays within the project directory, and false
        if it would escape to a higher directory. E.g. _path_is_safe('index.html')
        returns true, but _path_is_safe('../../../etc/password') returns false.
      """
      base = os.path.abspath(self._project_root)
      absolute_path = os.path.abspath(path)
      prefix = os.path.commonprefix([base, absolute_path])
      return prefix == base
  
file_path: lit/lit_nlp/lib/wsgi_app.py
imports: import mimetypes
  import os
  import time
  import traceback
  import wsgiref.handlers
  from absl import logging
  import six
  from six.moves.urllib.parse import urlparse
  from werkzeug import wrappers
label_desc: Use image node_id 4 for calling the App obj's underlying member method code with example usage: obj._PathIsSafe(path) and returns: unknown