code: def _unquote_cookie(s: str) -> str:
      
      # If there aren't any doublequotes,
      # then there can't be any special characters.  See RFC 2109.
      if s is None or len(s) < 2:
          return s
      if s[0] != '"' or s[-1] != '"':
          return s
  
      # We have to assume that we must decode this string.
      # Down to work.
  
      # Remove the "s
      s = s[1:-1]
  
      # Check for special sequences.  Examples:
      #    \012 --> \n
      #    \"   --> "
      #
      i = 0
      n = len(s)
      res = []
      while 0 <= i < n:
          o_match = _OctalPatt.search(s, i)
          q_match = _QuotePatt.search(s, i)
          if not o_match and not q_match:  # Neither matched
              res.append(s[i:])
              break
          # else:
          j = k = -1
          if o_match:
              j = o_match.start(0)
          if q_match:
              k = q_match.start(0)
          if q_match and (not o_match or k < j):  # QuotePatt matched
              res.append(s[i:k])
              res.append(s[k + 1])
              i = k + 2
          else:  # OctalPatt matched
              res.append(s[i:j])
              res.append(chr(int(s[j + 1 : j + 4], 8)))
              i = j + 4
      return _nulljoin(res)
docs: Handle double quotes and escaping in cookie values.
  
      This method is copied verbatim from the Python 3.5 standard
      library (http.cookies._unquote) so we don't have to depend on
      non-public interfaces.