Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > IE 6 Question Mark Wierdness

Reply
Thread Tools

IE 6 Question Mark Wierdness

 
 
Andrew Cowper
Guest
Posts: n/a
 
      09-15-2003

Anyone come across anything like this before? This is some javascript
validation of user input.

If ch is a question mark character, the test passes and false is
returned.

if ((ch==">") || (ch=="<") || (ch=="\\") ||
(ch=="|") || (ch=="\"") || (ch=="")) {

return false;
}

The problem is that the character '' is testing as equal to '?'. This
character is Latin 1 A6.

if ("?"=="") { alert("Holy Smoke!"); }

It seems to only happen on IE6 (I've tried 6.0.2800.1106).
Anyone got any thoughts?

Thanks
Andrew Cowper

--
Pick a different user name to email me.
 
Reply With Quote
 
 
 
 
asdf asdf
Guest
Posts: n/a
 
      09-15-2003
Hello, although I can't reproduce your problem, I'd like to suggest
that you could use a hash table to perform the checks.

var map = new Object();
map[">"] = true;
map["|"] = true;
..
..
..

if (map[input]) return found_in_map;
 
Reply With Quote
 
 
 
 
Douglas Crockford
Guest
Posts: n/a
 
      09-15-2003
> Hello, although I can't reproduce your problem, I'd like to suggest
> that you could use a hash table to perform the checks.
>
> var map = new Object();
> map[">"] = true;
> map["|"] = true;
> ....
> if (map[input]) return found_in_map;


This is a good place to use the object literal notation.

var map = {'>': true, '|': true, ...};
...
return map[input];

http://www.JSON.org

 
Reply With Quote
 
Greg
Guest
Posts: n/a
 
      09-15-2003
Andrew Cowper <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Anyone come across anything like this before? This is some javascript
> validation of user input.
>
> If ch is a question mark character, the test passes and false is
> returned.
>
> if ((ch==">") || (ch=="<") || (ch=="\\") ||
> (ch=="|") || (ch=="\"") || (ch=="")) {
>
> return false;
> }
>
> The problem is that the character '' is testing as equal to '?'. This
> character is Latin 1 A6.
>
> if ("?"=="") { alert("Holy Smoke!"); }
>
> It seems to only happen on IE6 (I've tried 6.0.2800.1106).
> Anyone got any thoughts?
>
> Thanks
> Andrew Cowper



I can't help much, but, yes, I've seen this frequently in cases where
wide to narrow character conversion was involved.

In my quick test (also IE6),

<meta http-equiv='content-type' content='text/html;charset=UTF-8'>
<!-- meta http-equiv='content-type'
content='text/html;charset=ISO-8859-1' -->
<script type='text/javascript'>
function test(){
var b = "?"=="";
alert('b: ' + b);
}
</script>

<a href='#a1' name='a1' id='a1' onclick='test(); return
false;'>test</a>

displays 'true' with UTF-8 but false with ISO-8859-1.

I suppose it's a question of how the == operator code in a given
browser compares a lower ASCII char to a wide char (not sure how many
bytes UTF-8 needs for ''). I suppose a conversion of the wide char to
a question mark might be intended to convey 'dunno what to make of
this'.

Not an expert. FWIW.
 
Reply With Quote
 
Andrew Cowper
Guest
Posts: n/a
 
      09-16-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (Greg) writes:

> Andrew Cowper <(E-Mail Removed)> wrote in
> message news:<(E-Mail Removed)>...
>> Anyone come across anything like this before? This is some javascript
>> validation of user input.
>>
>> if ("?"=="") { alert("Holy Smoke!"); }
>>


> displays 'true' with UTF-8 but false with ISO-8859-1.
>


Yes, we are serving our pages as UTF-8 so this fits. I think I'm just
going to forget about testing for that character. Thanks Greg (and
others) for your help...

Andrew Cowper

--
Pick a different user name to email me.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
To Mark Fitzpatrick, Juan Libre, Mark Rae, Steve Orr, Cowboy and other MVPs Cirene ASP .Net 5 05-17-2008 07:17 PM
Cisco 837 and Cisco VPN client wierdness.. any ideas? Christian Hewitt Cisco 1 04-30-2005 11:33 AM
AS5359 IP address Wierdness Jason Cisco 0 04-08-2005 04:49 PM
Datagrid Cell Spacing Wierdness Terry Olsen ASP .Net 2 03-29-2005 01:57 AM



Advertisments