Skip to content

[th/export-sanitize-newlines] properties: sanitize newlines ('\n') when exporting ovpn file

Thomas Haller requested to merge th/export-sanitize-newlines into master

Openvpn's ovpn configuration files cannot contain newlines as values, because

  • the parser reads the ovpn file line by line, splitting lines are newlines before considering quotation that spans multiple lines.
  • special special escape sequences like '\n' or '\0x012' are not supported. Escape sequences are only supported for "'", """, and verbatim spaces like "\ " (but not newline itself).

Note that newlines could be part of a valid configuration, for example as part of filenames.

That means, whenever exporting a configuration with newlines, it cannot be expressed, because we would end up with a quotation that breaks the line, tripping up the configuration parser of openvpn.

There is no way to make this configuration working. However, instead of writing syntatically wrong ovpn files, prefer to write valid ovpn files with mangled configuration. For that, replace newline characters with space.

Merge request reports