Bug 293247 - Some labels are not properly escaped
Summary: Some labels are not properly escaped
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 2.0.4
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: 2.0.5
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-03 21:59 UTC by Nicolas Brisset
Modified: 2012-02-28 22:04 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Brisset 2012-02-03 21:59:40 UTC
Version:           2.0.4
OS:                Linux

Legend items and left labels (units) are not properly escaped: e.g. _ gets interpreted as the beginning of a subscript.

Reproducible: Always

Steps to Reproduce:
- Modify a unit in TWIN1xxx and TWIN2xxx from the sample_data/ subdir of the kst source tree, e.g. Torq_req from N.m to N_m
- load Torq_req vs Time from TWIN1xxx 
- duplicate with the change data file tool to show Torq_req from TWIN2 as well
- activate "Show legend" 


Actual Results:  
1) The file path in the legend is not properly escaped (sample_*d*ata has d as a subscript)
2) The unit in the left label is not properly escaped

Expected Results:  
All strings should be properly escaped

Those are 2 concrete examples, but I think there are other places with similar issues. Barth, I'd appreciate if you could have a look at that because I don't have the overview how this works.

I think the right way to handle it would be to create a global method to escape strings before passing them to the renderer, something like "static QString KstString::escape(const QString& inString)" like QRegExp::escape().
We could then store unescaped string in all objects (names etc) and escape them just before rendering.
Comment 1 Netterfield 2012-02-10 21:34:49 UTC
The file name in the above example should be escaped.

The units should not, because you might have units in terms of some constant like k_b.  If you want N_m to not be subscripted, then you should use N\_m.  Superscripts are even more likely, such as m/s^2
Comment 2 Nicolas Brisset 2012-02-24 23:09:20 UTC
OK for your comment, what I can do is pre-escape unit names when reading them from file in the ASCII data source.
But a static public method KstString::escape() would be nice to avoid duplicating code...
Comment 3 Netterfield 2012-02-25 16:50:53 UTC
On Fri, Feb 24, 2012 at 6:09 PM, Nicolas Brisset
<nicolas.brisset@eurocopter.com> wrote:
> --- Comment #2 from Nicolas Brisset <nicolas brisset eurocopter com>  2012-02-24 23:09:20 ---
> OK for your comment, what I can do is pre-escape unit names when reading them
> from file in the ASCII data source.

I don't understand: your should be able to have the ascii data source
interpret m/s^2 as the 2 being a super script, shouldn't you?

you could have an option to 'disable latex interpretation', but it
would have to be optional.  Being able to have properly
formatted units with superscripts is pretty nice.
Comment 4 Netterfield 2012-02-28 19:58:26 UTC
SVN commit 1282831 by netterfield:


Properly escape special characters in file names.

Also, fix a bug in label positions coming out of 'maximize plot' mode.


 M  +5 -0      libkst/labelinfo.cpp  
 M  +1 -0      libkst/labelinfo.h  
 M  +14 -0     libkstapp/labelitem.cpp  
 M  +1 -0      libkstapp/labelitem.h  
 M  +3 -2      libkstapp/legenditem.cpp  
 M  +3 -3      libkstapp/viewitem.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1282831
Comment 5 Nicolas Brisset 2012-02-28 22:04:45 UTC
Thanks Barth!
I guess you are right about units, it is nice to be able to have them being typeset. The only thing is that I doubt users who may run into the issue will know how to solve the issue. But then, they'll probably ask on the list and we can tell them, or decide what to do.

For the rest, your fix seems to solve my issues.