示例#1
0
        private Transformation DeduceTransformation(string context, UnicodeTestCase tc, string canary)
        {
            //If the or clause is hit that also means that encoding occured.. we might want to display that info
            //at some point.. *Shrug*
            if (context.Contains(canary + tc.SourcePoint.Chr))
            {
                return(Transformation.None);
            }
            else if (DoesRegexMatch(context, tc.CreateSourceRepresentationsRegex(), canary))
            {
                return(Transformation.Encoded);
            }
            else if (tc.Target != null && context.Contains(canary + tc.Target.Chr))
            {
                return(Transformation.Transformed);
            }
            else if (tc.Target != null && DoesRegexMatch(context, tc.CreateTargetRepresentationsRegex(), canary))
            {
                //Should this be Normalization (Now transformation of some kind happend with encoding).
                return(Transformation.Transformed | Transformation.Encoded);
            }
            //Was replaced by the UNICODE and other Suggested REplacement Chars Such as ; ? 0xFFFD etc.
            foreach (UAUnicodeChar ch in UnicodeTestCase.GetReplacementCharList())
            {
                if (context.Contains(canary + ch.Chr))
                {
                    return(Transformation.Replacement);
                }
            }

            foreach (UAUnicodeChar ch in UnicodeTestCase.GetReplacementCharList())
            {
                if (DoesRegexMatch(context, UnicodeTestCase.CreateRegexFromChar(ch), canary))
                {
                    return(Transformation.Replacement | Transformation.Encoded);
                }
            }
            return(Transformation.Unknown);
        }