Results 1 to 9 of 9
  1. #1
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Generating XHTML with ASP - converter?

    I'm trying to convert a bunch of ASP pages from old-fashioned non-standards-compliant HTML to XHTML. It's more tedious than complex (more info: http://www.codeproject.com/html/htmltoxhtml.asp), but with tedium comes sloppiness and the desire for efficient tools. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    The HTML Tidy tool (http://tidy.sourceforge.net/) will convert an HTML page to XHTML with minimal prompting, but it completely ignores all the VBScript code that creates the bulk of the page, and it doesn't seem to fully understand <%=variable%> tags. While Tidy is an open source project and could be modified to read VBScript (if one knows C), and is available as a COM object (I think) for the VB-oriented, I surely could use a shortcut as it would be faster to fix all the files by hand than to develop this tool myself. (I suspect there wouldn't be a lot of enthusiasm among the open sourcerors to do it for me, given that VBScript is proprietary to Microsoft.)

    Anyone aware of any other tools that could help? I code in Wordpad and occasionally in FrontPage 2002, and publish to our intranet using drag and drop, so if the answer is "my editor does that," maybe I'll end up getting a new editor, too. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  2. #2
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generating XHTML with ASP - converter?

    this has NOTHING to do with your post but I noticed that XHTML require ""s for values on fields. Sending info to SQL server in a text box that may contain quotes or apostrophes will have to be handled prior to submission! I discovered a problem with text being truncated when quotes were entered (I was checking for apostrophes) and noticed I was wrapping the values in quotes, which caused the text to truncate....

    this is my standard apostrophe and quote escape scrub:

    <font face="Georgia">quote=chr(34)
    response.write "<input type=""hidden"" name=" & quote & item & quote & " value='" & Replace(Request.Form(item), "'", """") & "'>"
    </font face=georgia>

    The value string is wrapped with an apostrope, not quotes to handle the quote in the text stream. If you are using quotes to wrap values in XHTML then you will have to deal with quotes in the text itself!

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Generating XHTML with ASP - converter?

    Scrubbing is always good, as we discussed in the thread on SQL injection vulnerabilities (or maybe that was on the Access board). But in this case, the " marks required are in the input tags in the page you are serving to your user; they would surround the default values you are providing. I don't think XHTML changes the way the browser demarcates fields when it POSTs to the server, but I suppose anything is possible.

  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generating XHTML with ASP - converter?

    i'd recommend testing it to find out. i was plenty suprised to find that quotes in a string truncated the POST value (I know about the 'apostrophe bug' in SQL Server already) -- but I normally use single quotes on values where a space may occur. I have no idea what the best practices is in this area but it's true 'normal' HTML can accept values without quotes or apostrophes. If there's a good reason to use quotes let me know. (beside the fact that XHTML requires it).

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Generating XHTML with ASP - converter?

    I've converted two third of my pages (all ASP pages) and the functionality remains identical. Here's an example of where the default values are "quoted" (parameter values changed to protect the innocent):

    <input type="text" name="X" id="X" value="<%=Request("Y")%>" size="30" />

  6. #6
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generating XHTML with ASP - converter?

    what happens when you pass a text string containg quotes such as:

    value="< % = Request("Why as "Why"?") % >"

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Generating XHTML with ASP - converter?

    There are many reason that the above is impossible. The Request variables collection cannot contain any variables whose names include quotation marks. If you inserted that string as a constant, you would get a compile error because VBScript requires that you double the " mark to embed it in a string. Assuming you did all that, my application should truncate or refuse the input, since what is being searched will never include quotation marks.

    Here's something else you could try to test it out (name the file reload.asp to match the action url):

    <code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
    <title>ASP Submit Test</title>
    <style>
    form {display: table}
    fieldset {border: 1px solid gray}
    </style>
    </head>

    <body>
    <h3>Submit this page to see what happens!</h3>
    <hr />
    <h4>Try different values (including quotation marks if you like)</h4>
    <form method="post" action="reload.asp" name="form1" id="form1">
    <fieldset>
    <legend>Form 1</legend>
    <input type="text" name="form1text1" id="form1text2" value="<%=Request("form1text1")%>" size="25" />
    <input type="text" name="form1text2" id="form1text2" value="<%=Request("form1text2")%>" size="25" />


    <input type="submit" name="form1submit" id="form1submit" value="Submit to ASP" size="15" /></p>
    </fieldset>
    </form>
    <h4>Form variables dump:</h4>
    <%
    Response.Write Replace(Request.Form, "&", "")
    %>
    </body>
    </html></code>

    As you might expect, when the browser encouters a " in the midst of a value attribute, it truncates there and interprets the next several characters as a tag. So it would be desirable to validate the strings on the server however you code your form.

  8. #8
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generating XHTML with ASP - converter?

    what i was suggesting is seeing if quotes in a string passed to an XHTML form will truncate; sounds like they will when you try to re-display the info. The situation I encountered was that the data in a text field got truncated before the into was sent to the db (because of the way i was passing the value - i.e. by quote deliminated fields. I go no compile error, just dropped data.... If you don't handle quotes in the code then you'll experience data loss with no errors.

    anyway, it seems to me you will always have to include some scrubbing code with XHTML; because the standard requires quotes your scrubbing code should be very standard and part of your XHMTL 'toolbox'. This is nice, since it's predictable.

    btw do you save XHTML format with .htm or .html or some other extension?

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Generating XHTML with ASP - converter?

    > btw do you save XHTML format with .htm or .html or some other extension?

    I use .html or .asp, as the case may be. While other extensions are possible, I'm not using the "Strict" DTD, just the "Transitional" one, so I haven't gone over to the XML future at this point.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •