Bug 475765

Summary: FITS viewer truncates header strings (values & comments) at `/` characters
Product: [Applications] kstars Reporter: cgobat <cgobat>
Component: generalAssignee: Jasem Mutlaq <mutlaqja>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Minimal example of FITS header with slash(es)

Description cgobat 2023-10-17 19:55:59 UTC
Created attachment 162385 [details]
Minimal example of FITS header with slash(es)

SUMMARY
When a slash (`/`) character is present in a FITS header value or comment string, the string is truncated/split at that character.

STEPS TO REPRODUCE
1. Use KStars FITS viewer to open a FITS file that contains slashes in one or more header comments or value strings (see attachment for example)
2. Open header (i.e. `Ctrl-H`)
3. Note that the comments/values of interest are cut off where the slash should have been

OBSERVED RESULT
See the screenshot in this GitHub comment:
https://github.com/scriptorron/indi_pylibcamera/pull/49#issuecomment-1766943549

EXPECTED RESULT
I would expect the full comment field (up to the max 80-character-per-card limit, that is) to be displayed.

SOFTWARE/OS VERSIONS
I am personally able to reproduce this using KStars 3.4.1 on Ubuntu 20.04, 3.6.2 on Linux Mint Debian Edition 6, and 3.6.7 on Windows 10. I do not think this is an OS-specific thing.

ADDITIONAL INFORMATION
I suspect this is due to a parsing routine that is naïvely splitting the string on instances of the slash character without taking into account the presence of quotation marks (in the case of value strings) or the fact that only one slash (the first occurrence outside a value string) should be used to delimit the comment.

For reference, the header of the attached example is shown below:
SIMPLE  =                    T / conforms to FITS standard
BITPIX  =                    8 / array data type
NAXIS   =                    0 / number of array dimensions
EXTEND  =                    T
SLASHVAL= 'string w/ a slash'  / no slash here
SLASHCOM= 'no slash here'      / comment w/ a slash