473,385 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Curious Response.Write behavior with GUIDs as strings

Consider the following:

var GUID = Server.CreateObject("Scriptlet.TypeLib").GUID

Let's assume GUID is {9A46FCC9-A7A1-4C96-9394-B1A966CEC081}.

I happened to notice that if I concatenate this with any other string value,
Response.Write aborts after the 38th character of the GUID (the closing
brace):

Response.Write("xxx" + GUID + "yyy")
--> xxx{9A46FCC9-A7A1-4C96-9094-B1A966CEC081}

But the string *contains* those values:

Response.Write(("xxx" + GUID + "yyy").substring(43))
--> yyy

I first thing that caught my eye was the string length -- two characters
longer than I expected. This helped explain things:

Response.Write(escape("xxx" + GUID + "yyy"))
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%00%25yyy
^^^^^^

So my mystery characters are %00%25, right? Wrong. The %00 seems static, but
the next character appears to be random. Reloading a few times revealed no
real pattern (the GUID obviously changes, so this example is a
generalization):

--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%00%25yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%004yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%006yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%00Cyyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%00%20yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%00Dyyy

OK, so the string contains %00 and a garbage character. But what IS that
character? According to http://www.asciitable.com/, it is suppose to be a
(null) character. I can seemingly verify that this is not just a mapping
from a larger character set, since I get a non-zero
indexOf(String.fromCharCode(0)); more importantly, VBScript's Asc, AscB and
AscW functions all return 0.

It appears, then, that the problem is twofold. First of all, this assertion
is incorrect:
================================================== ==
guid = server.CreateObject("scriptlet.typelib").guid
Can be replaced with this:
guid = System.Guid.NewGuid.ToString()
================================================== ==
http://msdn.microsoft.com/asp.net/us...usingasst.aspx

Secondly, this behavior of Response.Write seems unindicated:
http://msdn.microsoft.com/library/en...resomwrite.asp


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #1
11 2330
http://www.aspfaq.com/2358

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:e9**************@TK2MSFTNGP09.phx.gbl...
Consider the following:

var GUID = Server.CreateObject("Scriptlet.TypeLib").GUID

Let's assume GUID is {9A46FCC9-A7A1-4C96-9394-B1A966CEC081}.

I happened to notice that if I concatenate this with any other string value, Response.Write aborts after the 38th character of the GUID (the closing
brace):

Response.Write("xxx" + GUID + "yyy")
--> xxx{9A46FCC9-A7A1-4C96-9094-B1A966CEC081}

But the string *contains* those values:

Response.Write(("xxx" + GUID + "yyy").substring(43))
--> yyy

I first thing that caught my eye was the string length -- two characters
longer than I expected. This helped explain things:

Response.Write(escape("xxx" + GUID + "yyy"))
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%00%25yyy
^^^^^^

So my mystery characters are %00%25, right? Wrong. The %00 seems static, but the next character appears to be random. Reloading a few times revealed no
real pattern (the GUID obviously changes, so this example is a
generalization):

--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%00%25yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%004yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%006yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%00Cyyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%00%20yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%00Dyyy

OK, so the string contains %00 and a garbage character. But what IS that
character? According to http://www.asciitable.com/, it is suppose to be a
(null) character. I can seemingly verify that this is not just a mapping
from a larger character set, since I get a non-zero
indexOf(String.fromCharCode(0)); more importantly, VBScript's Asc, AscB and AscW functions all return 0.

It appears, then, that the problem is twofold. First of all, this assertion is incorrect:
================================================== ==
guid = server.CreateObject("scriptlet.typelib").guid
Can be replaced with this:
guid = System.Guid.NewGuid.ToString()
================================================== ==
http://msdn.microsoft.com/asp.net/us...usingasst.aspx
Secondly, this behavior of Response.Write seems unindicated:
http://msdn.microsoft.com/library/en...resomwrite.asp


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 19 '05 #2
Aaron [SQL Server MVP] wrote:
http://www.aspfaq.com/2358


[sigh] I should have looked there.

BTW - do you have any idea why the last character is garbage?


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #3
No, that was one of those "we'll get back to you on that" things that I
reported around the time ASP.Net came into being. I've long since abandoned
any hope that ASP bugs will get any attention. Maybe I should raise the
issue about .Net though, because I have also seen it there...

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:#v**************@TK2MSFTNGP11.phx.gbl...
Aaron [SQL Server MVP] wrote:
http://www.aspfaq.com/2358
[sigh] I should have looked there.

BTW - do you have any idea why the last character is garbage?


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.

Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 19 '05 #4
It looks like the GUID property is returning a null-terminated string in a
40 character buffer. I have to conclude that this is a bug in a conversion
routine somewhere.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Aaron [SQL Server MVP] wrote:
http://www.aspfaq.com/2358
[sigh] I should have looked there.

BTW - do you have any idea why the last character is garbage?


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.

Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 19 '05 #5
Mark Schupp wrote:
It looks like the GUID property is returning a null-terminated string
in a 40 character buffer. I have to conclude that this is a bug in a
conversion routine somewhere.


I asked Eric Lippert, and he confirmed this. He also claimed responsibility:

...I was supposed to allocate 38 characters for the guid. For
some stupid reason I allocated 40 characters. A BSTR is
automatically terminated with a zero, so there's no need to
worry about it.

That is, the layout of the BSTR was supposed to be length = 38,
"{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" zero but turned out to
be length = 40, "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx}" zero
one-garbage-character zero

The garbage character is whatever happened to be on the heap
when the allocator fetched it...


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #6
So, Dave, do you have an enemy in Houston? A scorned lover, perhaps? ;-)

I forwarded several of the offensive messages, with headers, to google abuse
and his/her ISP. Hopefully someone smacks him/her upside the head for being
a childish pissant.
Jul 19 '05 #7
Aaron [SQL Server MVP] wrote:
So, Dave, do you have an enemy in Houston?
I may. I lived in Texas for 15 years, and I am, in fact, a Texas Aggie.
Years ago, I was an austin.general regular, and that group had plenty of
Houston contributors.
A scorned lover, perhaps?
;-)
If so, it was a one-way relationship, of which I was not made aware. I
suppose it could pre-date my current relationship, but that one dates to
1984 (and we've been married since 1985), so it would have to be one
extremely persistent grudge.
I forwarded several of the offensive messages, with headers, to
google abuse and his/her ISP. Hopefully someone smacks him/her
upside the head for being a childish pissant.


Thank you, though I'm not convinced it was directed at me. I have never
posted to any of the other groups listed, and I don't exactly have an
unusual name.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #8
> Thank you, though I'm not convinced it was directed at me. I have never
posted to any of the other groups listed, and I don't exactly have an
unusual name.


The other groups seem to have been picked at random. In any case, that kind
of grade-school nonsense has no place here, no matter who it was directed
at. I would have complained even if it were against Zane or CC. ;-)
Jul 19 '05 #9
> The other groups seem to have been picked at random.

Scratch that. I thought I saw different Newsgroups: lists, but looking
back, I was mistaken.
Jul 19 '05 #10
Aaron [SQL Server MVP] wrote:
The other groups seem to have been picked at random.


Scratch that. I thought I saw different Newsgroups: lists, but
looking back, I was mistaken.


I did a search on groups.google.com for "Bay Area Dave", and found that
someone named Bruce Carpenter has had a beef with such an individual for at
least 8 months. Odd that he should bring it here.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #11
Maybe he saw a similar enough Dave and assumed you were the same person.

Anyway, hopefully he has violated his T.O.S. and is now scrambling to find
another provider...

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:#F*************@TK2MSFTNGP11.phx.gbl...
Aaron [SQL Server MVP] wrote:
The other groups seem to have been picked at random.
Scratch that. I thought I saw different Newsgroups: lists, but
looking back, I was mistaken.


I did a search on groups.google.com for "Bay Area Dave", and found that
someone named Bruce Carpenter has had a beef with such an individual for

at least 8 months. Odd that he should bring it here.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 19 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: TinyTim | last post by:
I'm a newbie at ASP & HTML. It seems that when you use server side code and you're going to return a customized HTML form with several fields and labels, you have to do an extensive amount of...
35
by: Eitan | last post by:
Hello, How can I write a line (with carriage return + line feed) to the client ? response.write("abcd"), continue the last line, and doesn't put cr+lf. response.writeLn is illegal syntax... ...
35
by: Stan Milam | last post by:
The following code implements a strcat-like function which can receive a variable number of arguments. I thought it would be faster if I kept a pointer to the end of the string as it is built so...
1
by: vector | last post by:
I've got an application that generates GUIDs. A lot of GUIDs. Lots of GUIDs that end up in files on disk, taking up space. I'd like to continue using the Guid.NewGuid() function as my unique tag...
3
by: Farooq Khan | last post by:
why does Response.Write in a method of code-beind class when called from inpage code (i.e in <%---%>), after creating object of that class, fails when called while it works perfectly ok while...
1
by: Vish | last post by:
Hi All, I am trying to insert a GUID generated in .NET into my SQL Server tables. I am inserting it into a column of type uniqueidentifier. The GUID generated by ..NET has lower case alphabets...
10
by: Ron | last post by:
Hi, I currently am generating a report by to my end user by retrieving data from my back end DB and concatenating strings together and place this string concatenation within a Label control. I...
4
by: cbtechlists | last post by:
I have an ASP app that we've moved from a Windows 2000 to a Windows 2003 server (sql server 2000 to sql server 2005). The job runs fine on the old servers. Part of the app takes a recordset and...
2
by: daveh551 | last post by:
Okay, I asked a question a week or so ago asking for an explanation on relative URL's and the "~" symbol, and several people explained that the "~" is only usable when the URL is going to be parsed...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.