예제 #1
0
        /// <summary>
        /// Validate header tags H1 thru H6 tags.
        /// </summary>
        /// <param name="page">ASPX Page Properties.</param>
        /// <param name="tags">List of html header tags.</param>
        public static void HeaderTags(ref Scanner.ASPXPageProperties page, List <string> tags)
        {
            int   tagIndex = 1;
            Match m;

            int index = 0;

            if (tags.Count.Equals(0))
            {
                page.PageMessages.Add("PAG003");
            }
            else
            {
                while (tagIndex <= tags.Count)
                {
                    string pattern = string.Format(@"<h{0}>", tagIndex);
                    Regex  h       = new Regex(pattern, RegexOptions.IgnoreCase);
                    m = h.Match(RemoveWhiteSpaces(tags[0]));
                    if (m.Success.Equals(true))
                    {
                        page.PageMessages.Add("PAG005");
                    }

                    index++;
                    tagIndex++;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Displays details concerning a selected aspx server side control.
        /// </summary>
        /// <param name="page">Struct of properties about a server-side control.</param>
        public void FillForm(Scanner.ASPXPageProperties page)
        {
            this.ASPXPageName.Text = this.ASPXPageName.Text + page.FileName;
            this.Directory.Text    = this.Directory.Text + page.Path;

            foreach (string line in page.PageMessages)
            {
                listASPX.Items.Add(line.Trim());
                listMessages.Items.Add(Environment.NewLine);
            }

            listASPX.Items.Add(Environment.NewLine);
        }
예제 #3
0
 /// <summary>
 /// Displays details of selected row in GridViewPage.
 /// </summary>
 /// <param name="sender"> Object GridView.</param>
 /// <param name="e">Data Grid View Cell Event Args.</param>
 private void GridViewPage_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex > -1)
     {
         DataGridViewRow row = GridViewPage.Rows[e.RowIndex];
         if (row.Cells["SelectPage"].Selected.Equals(true))
         {
             Scanner.ASPXPageProperties aspxPageProperties = new Scanner.ASPXPageProperties();
             aspxPageProperties.PageMessages = new List <string>();
             aspxPageProperties = Scanner.AspxPages[row.Cells["ASPXPage"].Value.ToString()];
             ASPXPage aspxPage = new ASPXPage();
             aspxPage.FillForm(aspxPageProperties);
             aspxPage.ShowDialog();
         }
     }
 }
예제 #4
0
        /// <summary>
        /// Validate ASPX pages for Culture, Autopost, Tabindex.
        /// </summary>
        /// <param name="aspxControlsSorted">Sorted dictionary of individual asp net controls.</param>
        public static void ValidatePageAttributes(SortedDictionary <string, Scanner.ASPXControlProperties> aspxControlsSorted)
        {
            bool          pageErrorAutoPost = false;
            bool          pageErrorIndexTab = false;
            List <string> headerTags        = new List <string>();

            if (aspxControlsSorted.Count > 0)
            {
                Scanner.ASPXPageProperties page = new Scanner.ASPXPageProperties();
                if (page.PageMessages == null)
                {
                    page.PageMessages = new List <string>();
                }

                page.FileName = string.Empty;
                Scanner.ASPXControlProperties aspxControlProperties = new Scanner.ASPXControlProperties();
                foreach (KeyValuePair <string, Scanner.ASPXControlProperties> kvp in aspxControlsSorted.ToArray())
                {
                    aspxControlProperties = kvp.Value;
                    if (page.FileName.Equals(string.Empty))
                    {
                        page.FileName         = aspxControlProperties.FileName;
                        page.Path             = aspxControlProperties.Path;
                        page.NumberOfControls = 0;
                    }

                    if (!page.FileName.Equals(aspxControlProperties.FileName))
                    {
                        Rules.HeaderTags(ref page, headerTags);
                        Scanner.AspxPages.Add(page.FileName, page);
                        headerTags.Clear();
                        page.FileName         = aspxControlProperties.FileName;
                        page.Path             = aspxControlProperties.Path;
                        page.NumberOfControls = 0;
                        pageErrorAutoPost     = false;
                        pageErrorIndexTab     = false;
                        page.PageMessages.Clear();
                    }

                    if (aspxControlProperties.ControlType.Equals("HeaderTags"))
                    {
                        Rules.HeaderTags(ref page, headerTags);
                    }
                    else
                    {
                        page.NumberOfControls++;
                        if (Rules.Autopost(aspxControlProperties, ref page).Equals(true))
                        {
                            if (pageErrorAutoPost.Equals(false))
                            {
                                pageErrorAutoPost = true;
                                page.PageMessages.Add("AUT001");
                            }
                        }

                        if (Rules.TabIndex(aspxControlProperties, ref page).Equals(true))
                        {
                            if (pageErrorIndexTab.Equals(false))
                            {
                                pageErrorIndexTab = true;
                                page.PageMessages.Add("TAB001");
                            }
                        }
                    }
                }

                Scanner.AspxPages.Add(page.FileName, page);
            }
            ////todo: lanuage
            ////todo: display in new tab
        }
예제 #5
0
        /// <summary>
        /// Is tab index being used by an asp net control.
        /// </summary>
        /// <param name="aspxControlProperties">Individual ASPX Control.</param>
        /// <param name="page">Individual ASPX page.</param>
        /// <returns>Tue if control uses tab index.</returns>
        public static bool TabIndex(Scanner.ASPXControlProperties aspxControlProperties, ref Scanner.ASPXPageProperties page)
        {
            bool   status   = false;
            string pattern  = @"tabindex=\d[1-9]\w*";
            Regex  tabIndex = new Regex(pattern, RegexOptions.IgnoreCase);

            if (tabIndex.IsMatch(RemoveWhiteSpaces(aspxControlProperties.AspxControl)))
            {
                status = true;
            }

            return(status);
        }
예제 #6
0
        /// <summary>
        /// Is autopost used on aspx server-side control.
        /// </summary>
        /// <param name="aspxControlProperties">Individual ASPX Control.</param>
        /// <param name="page">Individual ASPX Page.</param>
        /// <returns>True if control uses autopost.</returns>
        public static bool Autopost(Scanner.ASPXControlProperties aspxControlProperties, ref Scanner.ASPXPageProperties page)
        {
            bool   status   = false;
            string pattern  = @"autopostback\w*";
            Regex  autopost = new Regex(pattern, RegexOptions.IgnoreCase);

            if (autopost.IsMatch(RemoveWhiteSpaces(aspxControlProperties.AspxControl)))
            {
                status = true;
            }

            return(status);
        }