Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-918

Extend StringEscapeUtils with escapeFilename() method

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • None
    • None
    • lang.*, lang.text.*
    • None

    Description

      It would be nice if StringEscapeUtils could take any string (include with backslash, forward slash, tab, CR, LF, extended unicode chars,...) and turn it into a valid filename, escaping the 'invalid' characters.

      Implementation might be OS-dependent or simply escape all characters which are invalid in at least one of the major OS (Unix/Windows/Mac)

      Rationale: it is quite common to receive uncontrolled text (from Web form, from mail parsing, ...) and need to turn it into some part of file/folder name (to create some workspace, archive data,...) which 'ressemble' (and +/- human readable) to the original free text.

      Could be very similar to escapeHtml(): replace each invalid char by %HexCodeOfChar - only the list of 'invalid chars' would be different.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ovierlinck Olivier Vierlinck
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: