views:

180

answers:

1

Why $_SERVER['HTTP_REFERER'] (PHP) and Request.ServerVariables("HTTP_REFERER") (ASP) return different result if query string has non english characters?

php return correct value but asp will not:

php: сабака

asp: ׁ׀°׀±׀°׀÷׀°

A: 

According to RFC 2616, characters not in ISO- 8859-1 should be specially encoded. Therefore it seems that whoever is sending you the headers is breaking the spec. See field-content and TEXT.

4.2 Message Headers

message-header = field-name ":" [ field-value ]
field-name     = token
field-value    = *( field-content | LWS )
field-content  = <the OCTETs making up the field-value
                 and consisting of either *TEXT or combinations
                 of token, separators, and quoted-string>

2.2 Basic Rules

TEXT           = <any OCTET except CTLs,
                 but including LWS>

The TEXT rule is only used for descriptive field contents and values that are not intended to be interpreted by the message parser. Words of *TEXT MAY contain characters from character sets other than ISO- 8859-1 [22] only when encoded according to the rules of RFC 2047 [14].

zildjohn01