Changeset 397 in code for trunk


Ignore:
Timestamp:
Aug 19, 2020, 10:22:32 AM (5 years ago)
Author:
contact
Message:

Escape user/network/entity characters in log file path

ZNC replaces slashes and backslashes with a dashes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/logger.go

    r392 r397  
    2929}
    3030
     31var escapeFilename = strings.NewReplacer("/", "-", "\\", "-")
     32
    3133func logPath(network *network, entity string, t time.Time) string {
    3234        user := network.user
    3335        srv := user.srv
    3436
    35         // TODO: handle/forbid network/entity names with illegal path characters
    3637        year, month, day := t.Date()
    3738        filename := fmt.Sprintf("%04d-%02d-%02d.log", year, month, day)
    38         return filepath.Join(srv.LogPath, user.Username, network.GetName(), entity, filename)
     39        return filepath.Join(srv.LogPath, escapeFilename.Replace(user.Username), escapeFilename.Replace(network.GetName()), escapeFilename.Replace(entity), filename)
    3940}
    4041
Note: See TracChangeset for help on using the changeset viewer.