Issue #622 on hold

GenericAspxLexer error when resources are used

Martin Holst Swende
created an issue

When using a VbNetAspxLexer parsing a file which begins like this :

{{{

!asp

<%@ Page Language="VB" MasterPageFile="~/Includes/Foo.master" Title="<%$Resources:Resource, FOO_BAR %>" %> }}}

The parser mistakes the first %> as the end of the tag, and does not invoke the vb-parser correctly. From GenericAspLexer: {{{

!python

tokens = {
    'root': [
        (r'(<%[@=#]?)(.*?)(%>)', bygroups(Name.Tag, Other, Name.Tag)),
        (r'(<script.*?>)(.*?)(</script>)', bygroups(using(XmlLexer),
                                                    Other,
                                                    using(XmlLexer))),
        (r'(.+?)(?=<)', using(XmlLexer)),
        (r'.+', using(XmlLexer)),
    ],
}

}}}

The expression '(%[@=#]?)(.*?)(%)' stops at the first %>.

Comments (3)

  1. Martin Holst Swende reporter

    This ugly patch seems to fix it, but it's not the "right" (tm) way to do it... :

                (r'(<%[@=#]?)(.*?%>") (%>)', bygroups(Name.Tag, Other,Name.Tag)),
                (r'(<%[@=#]?)(.*?)(%>)', bygroups(Name.Tag, Other, Name.Tag)),
    
  2. Martin Holst Swende reporter

    I am not a .NET expert, my example comes from some real-world testing. Some googling however located this http://msdn.microsoft.com/en-us/library/ms227427.aspx , where the following syntax is specified:

    The resource expression takes the following form, where Class is optional, unless the resource is a global one, and ResourceID is required:
    
    <%$ Resources: Class , ResourceID %>
    

    And here is an example from the same page:

    <asp:Button ID="Button1" 
                runat="server" 
                meta:resourcekey="Button1Resource1"
                Text="<%$ Resources:WebResources, Button1Caption %>" />
    

    So, it would appear that matching something along the lines of "<%(?\s)*"<%$[Rr]esources:[\S]+,[\S]+[\s]*%>"\s*%> may be a way to go...

  3. Log in to comment