TADS Bug Database

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000187TADS 3Otherpublic2013-01-28 22:482013-04-22 19:55
Assigned ToMichael Roberts 
PlatformMacintoshOSMacOSOS VersionX
Summary0000187: User-created HTML files being served as text/plain by TADS webserver
DescriptionI am creating a game and need to add an HTML file to webuires.

(Specifically, I am trying to get Ben Cressey's WebUI extension to work, since it was developed to allow direct execution of JS in the browser from the game - https://bitbucket.org/bcressey/t3ext/src/3092ba850e5efc0b4f057a27d5a08666accc355c/webui?at=master [^] - and this requires the use of an additional "script" IFRAME).

I've added the file to my local webuires directory and compiled the game for webui. I am then running the game locally (on my mac) by running t3launch.php through my local Apache, which shells out to frob and launches the game on a URL of the form:

http://localhost:49743/?TADS_session=e3673d8a-7e25-2d1e-cd781a208190-abf6 [^]

If I now navigate to:

http://localhost:49743/webuires/layoutwin.htm [^]

... I get that HTML page loading (can be verified by looking at the title bar, or doing view-source).
If I now navigate to:

http://localhost:49743/webuires/test.htm [^]

... I get the source of that HTML file displayed. If I check the dev console, it shows this file being served in the HTTP response as mime-type "text/plain".
Steps To Reproduce1. Download the attached ZIP of my code.
2. Compile thus: t3make -a -f gameWeb
3. Launch in a browser: http://localhost/TADS/t3launch.php?storyfile=http://localhost/TADS/games/htmltest/gameWeb.t3 [^]
4. On launch of the game, navigate to http://localhost:49743/webuires/layoutwin.htm [^] (correcting the port number if different) and note that this file is served as HTML correctly
5. Navigate to http://localhost:49743/webuires/test.htm [^] and note that this file is served as text, not HTML.
TagsNo tags attached.
Fixed In Version3.1.3
Attached Fileszip file icon htmltest.zip [^] (4,419 bytes) 2013-01-28 22:48

- Relationships

-  Notes
Michael Roberts (administrator)
2013-04-22 19:55

The problem is in the content-based detection of the content type, and it looks like the bug will only occur for short files, less than 512 bytes long. The code that reads the first chunk of the file to check its content was incorrectly assuming that the file was at least 512 bytes long, so it thought it was getting a read error if the file turned out to be shorter, and just gave up trying to detect the content and returned the generic text/plain. I've fixed it for the next version; in the meantime, you should be able to work around it by adding a couple of lines to webui.t to override the content type detection and set text/html as the content type for any resource file with a .htm or .html suffix. Find class WebResourceResFile, then look for the browerExtToMime property, and add the following to the list of translations:

   'htm' -> 'text/html',
   'html' -> 'text/html'

The only reason those overrides aren't in the library to start with is that the content-based detection is *supposed* to detect text/html files with or without the extensions, so omitting the suffix-based typing gives you more flexibility in naming your files. But as long as you're already using .htm suffixes anyway, adding the mappings should fix it for you for the time being.

- Issue History
Date Modified Username Field Change
2013-01-28 22:48 falmon New Issue
2013-01-28 22:48 falmon File Added: htmltest.zip
2013-04-22 19:55 Michael Roberts Fixed In Version => 3.1.3
2013-04-22 19:55 Michael Roberts Note Added: 0000324
2013-04-22 19:55 Michael Roberts Assigned To => Michael Roberts
2013-04-22 19:55 Michael Roberts Status new => resolved
2013-04-22 19:55 Michael Roberts Resolution open => fixed

Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker