|Anonymous | Login | Signup for a new account||2017-09-26 16:00 EDT|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0000187||TADS 3||Other||public||2013-01-28 22:48||2013-04-22 19:55|
|Assigned To||Michael Roberts|
|Summary||0000187: User-created HTML files being served as text/plain by TADS webserver|
|Description||I 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:
If I now navigate to:
... I get that HTML page loading (can be verified by looking at the title bar, or doing view-source).
If I now navigate to:
... 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 Reproduce||1. 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.
|Tags||No tags attached.|
|Fixed In Version||3.1.3|
|Attached Files||htmltest.zip [^] (4,419 bytes) 2013-01-28 22:48|
Michael Roberts (administrator)
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.
|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 - 2017 MantisBT Team|