Bug 115325 - [testcase] Tabs in strings are interpreted as 8 spaces, thus substring(m, n) is off by a few characters
Summary: [testcase] Tabs in strings are interpreted as 8 spaces, thus substring(m, n) ...
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml parsing (show other bugs)
Version: 3.4.2
Platform: Debian testing Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
: 115330 141122 170401 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-10-29 17:41 UTC by Reinhold Kainhofer
Modified: 2008-09-12 04:19 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Simple sample page to show the bug in kde 3.4 (and 3.5) (525 bytes, text/html)
2005-10-29 17:42 UTC, Reinhold Kainhofer
Details
source (177 bytes, text/html)
2008-09-10 23:02 UTC, lunter
Details
patch (1.64 KB, patch)
2008-09-11 01:58 UTC, Maksim Orlovich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Reinhold Kainhofer 2005-10-29 17:41:23 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    Debian testing/unstable Packages

A tab in a javascript string should always count as 1 character. However, konqueror from kde 3.4 (and according to Sho_ on IRC also konqueror from 3.5) seems to interpret a tab as 8 spaces rather than as one character. Thus the substring method can be severly off.

As an example, the following JavaScript code shows the problem (note that there is exactly one tab character between "Is" and "this", as well as between "No" and "Yes"!):

var myString='Is	this No	Yes Yes ';
var tmpAnswer=myString.substring(15,18);
document.write('<p>Is this correct: '+tmpAnswer+'</p>');

In Konqueror, the tab after the "Is" is counted as 8 spaces, thus the substring begins at "No ". In all other browsers (firefox and opera), the tabs are counted a as one character, so offset 15 is right at the last "Yes".
I'll attach the sample file for quickly checking the bug.

Cheers,
Reinhold
Comment 1 Reinhold Kainhofer 2005-10-29 17:42:46 UTC
Created attachment 13206 [details]
Simple sample page to show the bug in kde 3.4 (and 3.5)
Comment 2 George Staikos 2005-10-29 18:34:17 UTC
*** Bug 115330 has been marked as a duplicate of this bug. ***
Comment 3 George Staikos 2005-10-29 18:34:56 UTC
This is a KHTML parser bug.  The tabs are being expanded before they arrive at KJS.
Comment 4 FiNeX 2008-04-06 22:58:48 UTC
Confirmed even on konqueror 4.0.3
Comment 5 Maksim Orlovich 2008-09-10 17:08:33 UTC
*** Bug 141122 has been marked as a duplicate of this bug. ***
Comment 6 Maksim Orlovich 2008-09-10 17:12:20 UTC
*** Bug 170401 has been marked as a duplicate of this bug. ***
Comment 7 lunter 2008-09-10 23:01:05 UTC
http://pc44.one.pl/goorol/bugs/kde_001.html

IE, FF, Opera, Safari alert TRUE
KHTML alerts FALSE because wrongly interprets TAB char (chr(9)) as spaces
string!
Comment 8 lunter 2008-09-10 23:02:11 UTC
Created attachment 27357 [details]
source
Comment 9 Maksim Orlovich 2008-09-11 01:58:00 UTC
Created attachment 27361 [details]
patch

First try at fix... Or rather, it fixes that, but exposes some other likely bugs that need to be sorted out before committing.
Comment 10 Maksim Orlovich 2008-09-12 04:19:01 UTC
Fixed in r860109