Exemplo n.º 1
0
 /// <summary>
 /// Initializes the HTML safe list.
 /// </summary>
 private static void InitializeSafeList()
 {
     SyncLock.EnterWriteLock();
     try
     {
         if (characterValues == null)
         {
             characterValues = SafeList.Generate(0xFF, SafeList.PercentThenHexValueGenerator);
             SafeList.PunchSafeList(ref characterValues, UrlSafeList());
         }
     }
     finally
     {
         SyncLock.ExitWriteLock();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the LDAP DN safe lists.
        /// </summary>
        /// <returns>The DN safe list.</returns>
        private static char[][] InitialiseDistinguishedNameSafeList()
        {
            char[][] result = SafeList.Generate(255, SafeList.HashThenHexValueGenerator);
            SafeList.PunchSafeList(ref result, DistinguishedNameSafeList());

            // Now mark up the specially listed characters from http://www.ietf.org/rfc/rfc2253.txt
            EscapeDistinguisedNameCharacter(ref result, ',');
            EscapeDistinguisedNameCharacter(ref result, '+');
            EscapeDistinguisedNameCharacter(ref result, '"');
            EscapeDistinguisedNameCharacter(ref result, '\\');
            EscapeDistinguisedNameCharacter(ref result, '<');
            EscapeDistinguisedNameCharacter(ref result, '>');
            EscapeDistinguisedNameCharacter(ref result, ';');

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Marks characters from the specified languages as safe.
        /// </summary>
        /// <param name="lowerCodeCharts">The combination of lower code charts to use.</param>
        /// <param name="lowerMidCodeCharts">The combination of lower mid code charts to use.</param>
        /// <param name="midCodeCharts">The combination of mid code charts to use.</param>
        /// <param name="upperMidCodeCharts">The combination of upper mid code charts to use.</param>
        /// <param name="upperCodeCharts">The combination of upper code charts to use.</param>
        /// <remarks>The safe list affects all HTML and XML encoding functions.</remarks>
        public static void MarkAsSafe(
            LowerCodeCharts lowerCodeCharts,
            LowerMidCodeCharts lowerMidCodeCharts,
            MidCodeCharts midCodeCharts,
            UpperMidCodeCharts upperMidCodeCharts,
            UpperCodeCharts upperCodeCharts)
        {
            if (lowerCodeCharts == currentLowerCodeChartSettings &&
                lowerMidCodeCharts == currentLowerMidCodeChartSettings &&
                midCodeCharts == currentMidCodeChartSettings &&
                upperMidCodeCharts == currentUpperMidCodeChartSettings &&
                upperCodeCharts == currentUpperCodeChartSettings)
            {
                return;
            }

            SyncLock.EnterWriteLock();
            try
            {
                if (characterValues == null)
                {
                    characterValues = SafeList.Generate(65536, SafeList.HashThenValueGenerator);
                }

                SafeList.PunchUnicodeThrough(
                    ref characterValues,
                    lowerCodeCharts,
                    lowerMidCodeCharts,
                    midCodeCharts,
                    upperMidCodeCharts,
                    upperCodeCharts);

                ApplyHtmlSpecificValues();

                currentLowerCodeChartSettings    = lowerCodeCharts;
                currentLowerMidCodeChartSettings = lowerMidCodeCharts;
                currentMidCodeChartSettings      = midCodeCharts;
                currentUpperMidCodeChartSettings = upperMidCodeCharts;
                currentUpperCodeChartSettings    = upperCodeCharts;
            }
            finally
            {
                SyncLock.ExitWriteLock();
            }
        }
        /// <summary>
        /// Marks characters from the specified languages as safe.
        /// </summary>
        /// <param name="lowerCodeCharts">The combination of lower code charts to use.</param>
        /// <param name="lowerMidCodeCharts">The combination of lower mid code charts to use.</param>
        /// <param name="midCodeCharts">The combination of mid code charts to use.</param>
        /// <param name="upperMidCodeCharts">The combination of upper mid code charts to use.</param>
        /// <param name="upperCodeCharts">The combination of upper code charts to use.</param>
        /// <remarks>The safe list affects all HTML and XML encoding functions.</remarks>
        public static void MarkAsSafe(
            LowerCodeCharts lowerCodeCharts,
            LowerMidCodeCharts lowerMidCodeCharts,
            MidCodeCharts midCodeCharts,
            UpperMidCodeCharts upperMidCodeCharts,
            UpperCodeCharts upperCodeCharts)
        {
            if (lowerCodeCharts == currentLowerCodeChartSettings &&
                lowerMidCodeCharts == currentLowerMidCodeChartSettings &&
                midCodeCharts == currentMidCodeChartSettings &&
                upperMidCodeCharts == currentUpperMidCodeChartSettings &&
                upperCodeCharts == currentUpperCodeChartSettings)
            {
                return;
            }

            AcquireWriteLock();
            try
            {
                // Reset back to everything hashed.
                characterValues = SafeList.Generate(65536, SafeList.HashThenValueGenerator);

                SafeList.PunchUnicodeThrough(
                    ref characterValues,
                    lowerCodeCharts,
                    lowerMidCodeCharts,
                    midCodeCharts,
                    upperMidCodeCharts,
                    upperCodeCharts);

                ApplyHtmlSpecificValues();

                currentLowerCodeChartSettings    = lowerCodeCharts;
                currentLowerMidCodeChartSettings = lowerMidCodeCharts;
                currentMidCodeChartSettings      = midCodeCharts;
                currentUpperMidCodeChartSettings = upperMidCodeCharts;
                currentUpperCodeChartSettings    = upperCodeCharts;
            }
            finally
            {
                ReleaseWriteLock();
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes the HTML safe list.
 /// </summary>
 private static void InitialiseSafeList()
 {
     SyncLock.EnterWriteLock();
     try
     {
         if (characterValues == null)
         {
             characterValues = SafeList.Generate(0xFFFF, SafeList.HashThenValueGenerator);
             SafeList.PunchUnicodeThrough(
                 ref characterValues,
                 LowerCodeCharts.Default,
                 LowerMidCodeCharts.None,
                 MidCodeCharts.None,
                 UpperMidCodeCharts.None,
                 UpperCodeCharts.None);
             ApplyHtmlSpecificValues();
         }
     }
     finally
     {
         SyncLock.ExitWriteLock();
     }
 }
 /// <summary>
 /// Initializes the HTML safe list.
 /// </summary>
 private static void InitialiseSafeList()
 {
     AcquireWriteLock();
     try
     {
         if (characterValues == null)
         {
             // We use decimal encoding to support some older Japanese mobile browsers which don't support hex encoding.
             characterValues = SafeList.Generate(0xFFFF, SafeList.HashThenValueGenerator);
             SafeList.PunchUnicodeThrough(
                 ref characterValues,
                 currentLowerCodeChartSettings,
                 currentLowerMidCodeChartSettings,
                 currentMidCodeChartSettings,
                 currentUpperMidCodeChartSettings,
                 currentUpperCodeChartSettings);
             ApplyHtmlSpecificValues();
         }
     }
     finally
     {
         ReleaseWriteLock();
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes the Url Path safe list.
 /// </summary>
 /// <returns>A list of characters and their encoded values for URL encoding.</returns>
 private static char[][] InitialisePathSafeList()
 {
     char[][] result = SafeList.Generate(255, SafeList.PercentThenHexValueGenerator);
     SafeList.PunchSafeList(ref result, UrlPathSafeList());
     return(result);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes the CSS safe list.
 /// </summary>
 /// <returns>
 /// The CSS safe list.
 /// </returns>
 private static char[][] InitialiseSafeList()
 {
     char[][] result = SafeList.Generate(0xFF, SafeList.SlashThenSixDigitHexValueGenerator);
     SafeList.PunchSafeList(ref result, CssSafeList());
     return(result);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes the LDAP filter safe list.
 /// </summary>
 /// <returns>The LDAP filter safe list.</returns>
 private static char[][] InitialiseFilterSafeList()
 {
     char[][] result = SafeList.Generate(255, SafeList.SlashThenHexValueGenerator);
     SafeList.PunchSafeList(ref result, FilterEncodingSafeList());
     return(result);
 }