好奇的Response.Write行为与GUID作为字符串 [英] Curious Response.Write behavior with GUIDs as strings

查看:50
本文介绍了好奇的Response.Write行为与GUID作为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑以下事项:


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


让''假设GUID是{9A46FCC9-A7A1-4C96-9394-B1A966CEC081}。


我碰巧注意到如果我将其与任何其他字符串值连接起来,

Response.Write在GUID的第38个字符(结束

大括号)后中止:


Response.Write(" xxx" + GUID +" ; yyy)

- > xxx {9A46FCC9-A7A1-4C96-9094-B1A966CEC081}

但字符串*包含*那些值:


Response.Write(( " xxx" + GUID +" yyy")。s​​ubstring(43))

- > yyy


首先引起我注意的是字符串长度 - 两个字符

比我预期的要长。这有助于解释事情:


Response.Write(转义(" xxx" + GUID +" yyy"))

- > xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D%00%25yyy

^^^^^^


所以我的神秘人物是%00 %25,对吗?错误。 %00似乎是静态的,但

下一个字符似乎是随机的。重新加载几次显示没有

真实模式(GUID明显改变,所以这个例子是

概括):


- > 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


好​​的,所以字符串包含%00和垃圾字符。但那是什么

字符?根据 http://www.asciitable.com/ ,它被认为是一个

(null)字符。我似乎可以验证这不仅仅是一个来自更大字符集的映射

,因为我得到一个非零的
indexOf(String.fromCharCode(0));更重要的是,VBScript的Asc,AscB和

AscW函数都返回0.


然后,看来这个问题是双重的。首先,这个断言

是不正确的:

========================= ========================= ==

guid = server.CreateObject(" scriptlet.typelib")。guid

可替换为:

guid = System.Guid.NewGuid.ToString()

========= ========================================= ==
http://msdn.microsoft.com/asp .net / us ... usingasst.aspx


其次,Response.Write的这种行为似乎没有表现出来:
http://msdn.microsoft.com/library/en...resomwrite.asp


-

戴夫安德森


将阅读未经请求的商业电子邮件每条消息的费用为500美元。使用

此电子邮件地址即表示同意这些条款。请不要直接联系

我或要求我直接与您联系以获取帮助。如果您的问题值得询问,那么值得发帖。

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.

推荐答案

每条消息500条。使用

此电子邮件地址即表示同意这些条款。请不要直接联系

我或要求我直接与您联系以获取帮助。如果你的问题值得询问,那就值得发帖了。
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.


http://www.aspfaq.com/2358


-
http://www.aspfaq.com/

(反向地址回复。)


" Dave Anderson" < GT ********** @ spammotel.com>在消息中写道

news:e9 ************** @ TK2MSFTNGP09.phx.gbl ...
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...
请考虑以下事项:< br =>
var GUID = Server.CreateObject(" Scriptlet.TypeLib")。GUID

我们假设GUID是{9A46FCC9-A7A1-4C96-9394-B1A966CEC081}。

我偶然注意到,如果我将其与任何其他字符串
值连接,则Response.Write在GUID的第38个字符(结束
大括号)后中止:

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

但字符串*包含*那些值:

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

首先引起我注意的是字符串长度 - 两个字符比我预期的要长。这有助于解释事情:

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

所以我的神秘人物是%00%25,对吗?错误。 %00似乎是静态的,
但下一个字符似乎是随机的。重新加载几次显示没有
真实模式(GUID明显改变,所以这个例子是一个概括):

- > 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

好的,所以字符串包含%00和垃圾字符。但是那个
字符是什么?根据 http://www.asciitable.com/ ,它被认为是一个
(null)字符。我似乎可以验证这不仅仅是来自更大字符集的映射,因为我得到一个非零的索引(String.fromCharCode(0));更重要的是,VBScript的Asc,AscB
和AscW函数都返回0.

然后,问题是双重的。首先,这个
断言是不正确的:
================================= ================= ==
guid = server.CreateObject(" scriptlet.typelib")。guid
可以替换为:
guid = System.Guid.NewGuid.ToString()
================================= ================= ==
http://msdn.microsoft.com/asp.net/us...usingasst.aspx
其次,这种响应的行为.Write似乎没有表现出来:
http ://msdn.microsoft.com/library/en...resomwrite.asp


- 戴夫安德森

未经请求的商业电子邮件将以每封邮件
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的成本阅读。
使用此电子邮件地址即表示同意这些条款。请不要
直接与我联系或要求我直接与您联系以获取帮助。如果您的问题值得询问,那就值得发帖。
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.



这篇关于好奇的Response.Write行为与GUID作为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆