< Summary

Information
Class: Renci.SshNet.RemotePathTransformation
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\RemotePathTransformation.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 143
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.cctor()100%1100%
get_ShellQuote()100%1100%
get_None()100%1100%
get_DoubleQuote()100%1100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\RemotePathTransformation.cs

#LineLine coverage
 1namespace Renci.SshNet
 2{
 3    /// <summary>
 4    /// Provides access to built-in remote path transformations.
 5    /// </summary>
 6    /// <remarks>
 7    /// References:
 8    /// <list type="bullet">
 9    ///   <item>
 10    ///     <description><a href="http://pubs.opengroup.org/onlinepubs/7908799/xcu/chap2.html">Shell Command Language</a
 11    ///   </item>
 12    ///   <item>
 13    ///     <description><a href="https://earthsci.stanford.edu/computing/unix/shell/specialchars.php">Unix C-Shell spec
 14    ///   </item>
 15    ///   <item>
 16    ///     <description><a href="https://docstore.mik.ua/orelly/unix3/upt/ch27_13.htm">Differences Between Bourne and C
 17    ///   </item>
 18    ///   <item>
 19    ///     <description><a href="https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quot
 20    ///   </item>
 21    /// </list>
 22    /// </remarks>
 23    public static class RemotePathTransformation
 24    {
 425        private static readonly IRemotePathTransformation ShellQuoteTransformation = new RemotePathShellQuoteTransformat
 426        private static readonly IRemotePathTransformation NoneTransformation = new RemotePathNoneTransformation();
 427        private static readonly IRemotePathTransformation DoubleQuoteTransformation = new RemotePathDoubleQuoteTransform
 28
 29        /// <summary>
 30        /// Gets a <see cref="IRemotePathTransformation"/> that quotes a path in a way to be suitable to be used with a 
 31        /// </summary>
 32        /// <returns>
 33        /// A quoted path.
 34        /// </returns>
 35        /// <remarks>
 36        /// <para>
 37        /// If a path contains a single-quote, that character is embedded in quotation marks (eg. "'").
 38        /// Sequences of single-quotes are grouped in a single pair of quotation marks.
 39        /// </para>
 40        /// <para>
 41        /// An exclamation mark in a path is escaped with a backslash. This is necessary because C Shell
 42        /// interprets it as a meta-character for history substitution even when enclosed in single quotes
 43        ///  or quotation marks.
 44        /// </para>
 45        /// <para>
 46        /// All other characters are enclosed in single quotes. Sequences of such characters are grouped
 47        /// in a single pair of single quotes.
 48        /// </para>
 49        /// </remarks>
 50        /// <example>
 51        /// <list type="table">
 52        ///   <listheader>
 53        ///     <term>Original</term>
 54        ///     <term>Transformed</term>
 55        ///   </listheader>
 56        ///   <item>
 57        ///     <term>/var/log/auth.log</term>
 58        ///     <term>'/var/log/auth.log'</term>
 59        ///   </item>
 60        ///   <item>
 61        ///     <term>/var/mp3/Guns N' Roses</term>
 62        ///     <term>'/var/mp3/Guns N'"'"' Roses'</term>
 63        ///   </item>
 64        ///   <item>
 65        ///     <term>/var/garbage!/temp</term>
 66        ///     <term>'/var/garbage'\!'/temp'</term>
 67        ///   </item>
 68        ///   <item>
 69        ///     <term>/var/would be 'kewl'!, not?</term>
 70        ///     <term>'/var/would be '"'"'kewl'"'"\!', not?'</term>
 71        ///   </item>
 72        ///   <item>
 73        ///     <term></term>
 74        ///     <term>''</term>
 75        ///   </item>
 76        ///   <item>
 77        ///     <term>Hello &quot;World&quot;</term>
 78        ///     <term>'Hello "World"'</term>
 79        ///   </item>
 80        /// </list>
 81        /// </example>
 82        public static IRemotePathTransformation ShellQuote
 83        {
 57084            get { return ShellQuoteTransformation; }
 85        }
 86
 87        /// <summary>
 88        /// Gets a <see cref="IRemotePathTransformation"/> that performs no transformation.
 89        /// </summary>
 90        /// <remarks>
 91        /// Recommended for servers that do not require any character to be escaped or enclosed in quotes,
 92        /// or when paths are guaranteed to never contain any special characters (such as #, &quot;, ', $, ...).
 93        /// </remarks>
 94        public static IRemotePathTransformation None
 95        {
 24396            get { return NoneTransformation; }
 97        }
 98
 99        /// <summary>
 100        /// Gets a <see cref="IRemotePathTransformation"/> that encloses a path in double quotes, and escapes any embedd
 101        /// </summary>
 102        /// <value>
 103        /// A transformation that encloses a path in double quotes, and escapes any embedded double quote with
 104        /// a backslash.
 105        /// </value>
 106        /// <example>
 107        /// <list type="table">
 108        ///   <listheader>
 109        ///     <term>Original</term>
 110        ///     <term>Transformed</term>
 111        ///   </listheader>
 112        ///   <item>
 113        ///     <term>/var/log/auth.log</term>
 114        ///     <term>&quot;/var/log/auth.log&quot;</term>
 115        ///   </item>
 116        ///   <item>
 117        ///     <term>/var/mp3/Guns N' Roses</term>
 118        ///     <term>&quot;/var/mp3/Guns N' Roses&quot;</term>
 119        ///   </item>
 120        ///   <item>
 121        ///     <term>/var/garbage!/temp</term>
 122        ///     <term>&quot;/var/garbage!/temp&quot;</term>
 123        ///   </item>
 124        ///   <item>
 125        ///     <term>/var/would be 'kewl'!, not?</term>
 126        ///     <term>&quot;/var/would be 'kewl'!, not?&quot;</term>
 127        ///   </item>
 128        ///   <item>
 129        ///     <term></term>
 130        ///     <term>&quot;&quot;</term>
 131        ///   </item>
 132        ///   <item>
 133        ///     <term>Hello &quot;World&quot;</term>
 134        ///     <term>&quot;Hello \&quot;World&quot;</term>
 135        ///   </item>
 136        /// </list>
 137        /// </example>
 138        public static IRemotePathTransformation DoubleQuote
 139        {
 981140            get { return DoubleQuoteTransformation; }
 141        }
 142    }
 143}