1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2025-01-13 19:56:40 +00:00
Commit graph

190 commits

Author SHA1 Message Date
4ff6719077 Fix bug in the mime parser.
The token rule was matching even when the quoted_string
rule should have matched, which was preventing the "
stripping to work. In fact quoted_string was never being
used.
Also improve formatting of long lines.
2017-05-25 19:09:11 +01:00
5d4041aed8 Minor style change. 2017-05-25 00:51:39 +01:00
ea55602f6b Implement mime_split.
It will be used to detect received content types.
2017-05-25 00:51:26 +01:00
4e32006e08 Don't respond if the request method is unexpected.
This includes the jolly responder, which now only works
for GET requests.
2017-05-24 19:09:42 +01:00
9fff9d793c Move ip requesting code into a separate file and make hashing configurable at build time.
New code tries to guess a per-visitor IP address and uses
that (or its hash) to tell users apart.
This patch also adds a TAWASHI_WITH_IP_LOGGING cmake option
to enable or disable logging the IP address of your visitors
in various places (just one right now but don't assume things
to remain this way).
Also added a couple new CGI environment variables.
2017-05-24 09:34:52 +01:00
1507c79503 Clean up and make a separate class for pasties from curl-style requests. 2017-05-24 09:05:03 +01:00
53b5a1a2af Hack to quickly get a new pastie's address when invoked from curl. 2017-05-23 20:34:46 +01:00
847988f4bd No need to prepare mustache context if no body is required. 2017-05-23 20:24:56 +01:00
7549c0e664 Don't crash when a pastie doesn't exist, redirect to error page instead. 2017-05-23 20:15:41 +01:00
8b94672b25 Register a separate maker for requests to "" POST. 2017-05-23 19:59:49 +01:00
27881ed0f0 Allow registering makers specific to POST or GET requests. 2017-05-23 19:59:49 +01:00
014f18ec57 Simplify prefix len calculation and make it more flexible.
The prefix in tawashi.ini now can omit the trailing /.
If missing, it will still be trimmed from PATH_INFO if
necessary.
2017-05-23 19:59:49 +01:00
2571e70093 Allow to give the css file for the highlighter in tawashi.ini 2017-05-23 18:31:55 +01:00
7ada0f155b Make non-highlighted pasties white so they are readable.
Also disable line number generation as I plan to add them
in a different way later on.
2017-05-23 09:24:11 +01:00
7115e9eb63 Use a light colours style for highlighted pasties. 2017-05-23 09:14:33 +01:00
54d50cf6bc Basic check to tell if a string looks like a possibly valid number. 2017-05-22 21:04:26 +01:00
51810fa2f2 Always remove the trailing slash from computed URI. 2017-05-22 20:32:20 +01:00
6ea74d090a Set plain text mode *before* returning. 2017-05-22 20:28:18 +01:00
e2437a6b12 Add more logging and error checking. 2017-05-22 09:27:17 +01:00
d3319512f4 Case-insensitive check for HTTPS=on. 2017-05-19 19:48:31 +01:00
58c3f5c224 Log an error if host_path looks wrong. 2017-05-19 19:14:07 +01:00
e84e968ff6 Remove unused property. 2017-05-19 10:01:36 +01:00
34daf8e411 Decompose the base_uri option.
This allows support for having tawashi in a subdirectory
of your domain, eg http://example.com/tawashi
2017-05-19 10:01:22 +01:00
810c321515 Redirects always use 3xx status codes. 2017-05-18 22:38:09 +01:00
c6955cd8b9 Heineus bug fixed. 2017-05-18 20:19:50 +01:00
2e4d869370 Individually log failure for non-vital missing POST variables. 2017-05-18 19:17:22 +01:00
71ec9925f4 Fix sent http status codes. 2017-05-18 19:17:22 +01:00
aaa28d3454 Assign the actual numbers to the HTTP status codes enum.
This allows me to get rid of a good deal of crap.
2017-05-18 19:17:22 +01:00
4eb4261f4a This makes it quick to just delete the copy constructor.
Useful if you want to see where copy is done instead of move.
2017-05-18 19:17:22 +01:00
cdd23d35d0 Make on_process() return an HttpHeader.
Response type is now decided by on_process' return value.
2017-05-18 19:17:22 +01:00
c5f2bc055a Append the protocol to the uri from the code.
This means if you set uri name to http://example.com in the
config file you will actually get base_uri to be
http://http://example.com.
2017-05-18 19:17:22 +01:00
59a5d35ee0 Try to fix redirect not working properly. 2017-05-17 00:03:43 +01:00
5a4794240b Disable colouring when lang token is "colorless". 2017-05-16 23:07:00 +01:00
aa9e1f884f Rename text html page to pastie and get rid of paste.
So confusing! :s
2017-05-16 23:01:19 +01:00
85f6781d81 Fix tawashi sending back an html response even for redirects. 2017-05-16 22:58:09 +01:00
f19d78222f Clarify log entry 2017-05-16 22:16:33 +01:00
a1fa8cc1d2 Bugfix, don't redirect when the returned token is empty. 2017-05-16 22:06:36 +01:00
e77b9dafbb Log when redirecting to the error page. 2017-05-16 21:52:48 +01:00
8345c300a8 Add some debug logging and change level to trace. 2017-05-16 19:14:22 +01:00
ed4a02f4bb Setup the logger based on the log_file setting in tawashi.ini.
With this change I had to swap the order in which what settings
file as being loaded and the initialization of the logger itself.
This is because the logger now depends on the settings file,
so it can't be used before the setting file got parsed.
2017-05-16 19:11:09 +01:00
10da16051c Organize exceptions so it's easy to log errors locally. 2017-05-16 18:54:00 +01:00
32eadfc64d Pull some code out from main(). 2017-05-16 18:52:34 +01:00
75bd68c53e More logging 2017-05-15 23:47:01 +01:00
34c23659e9 Log files that mustache is trying to open as info. 2017-05-15 23:45:13 +01:00
0c7d08e299 Use a smaller type for string lengths. 2017-05-15 23:41:47 +01:00
8585e5baf5 Calculate string lengths at build time. 2017-05-15 23:38:39 +01:00
00f32d43d3 Fix displaying error messages in error response. 2017-05-15 21:46:35 +01:00
ba1b417f07 Fix wrong parameter in redirect address. 2017-05-15 09:33:31 +01:00
9b28b2d274 Add a --show-paths switch to print hardcoded paths and info. 2017-05-15 09:26:29 +01:00
7fc7e2fba8 Remove test-only stuff that is not necessary anymore.
Env reads environment variables from the list it receives
from main(), so I can also pass it a forged list now
without needing extra classes with sometimes-virtual methods
or other cruft.
2017-05-15 09:18:11 +01:00
c7545f27cf Add some missing environment variables.
Also add a description of what they're for, at least
some of them.
2017-05-14 14:51:50 +01:00
57dc0c7717 Add reason_code to string lookup. 2017-05-14 03:43:38 +01:00
ec80734625 Add http status codes and save dummy error into the mstch context. 2017-05-14 03:38:41 +01:00
4d31323bb1 Redirect to error.cgi when saving fails.
Not working yet, still getting there.
2017-05-12 22:46:54 +01:00
73707c2ad0 Revert "Pass the ResponseFactory object down to the Response itself."
This reverts commit 3bc6c56c03.
2017-05-12 22:18:03 +01:00
3bc6c56c03 Pass the ResponseFactory object down to the Response itself. 2017-05-12 09:36:01 +01:00
10da75caf5 Remove parameters from Response's constructor.
They can safely be defaulted and derived classes can
change their preferences later inside their constructor
if they need to.
2017-05-12 09:18:49 +01:00
f286507edf Delay fast subsequent pasties from the same IP. 2017-05-11 18:50:56 +01:00
9e63a648a1 Protect against fast flooding from the same ip. 2017-05-11 09:48:18 +01:00
d449781c40 Add unit test for utf8 sanitization. 2017-05-10 20:47:24 +01:00
13e46ab1e6 Replace nullchars with #.
There is also a glib-based implementation but I'm not
sure about it yet.
2017-05-10 20:45:26 +01:00
ed1343bd7b Pass the istream to read_post instead of assuming std::cin. 2017-05-10 20:42:42 +01:00
9e1e18dcf0 Set default.lang if user's lang is not found. 2017-05-08 19:48:09 +01:00
07135f215c Delete get_env, which confused me a lot.
Get raw environment variables directly from main().
Add code to split on '=' in cgi_environment_vars and only pick
the ones that are interesting, just as before.
2017-05-08 19:46:14 +01:00
376b34c1d0 Add todo comment. 2017-05-06 21:57:31 +01:00
df384f5128 Add unit test for IndexResponse. 2017-05-06 21:49:46 +01:00
f5f19350ea Make SafeStackObject implicitly up-castable. 2017-05-06 21:48:45 +01:00
cd1be59cfa Pass the output stream and cgi_env to Response.
Mask the fact that they are globals, because I need
to be able to pass different classes in order to be
able to write unit tests for response classes.
2017-05-06 19:48:44 +01:00
8980a1d1ff I don't really need to store the page name in the base class. 2017-05-06 19:16:57 +01:00
ebed6fd1d4 Fix unit test for IniParser.
I'm not sure why graph needs the -eol part for the
value part, hopefully I'll find out at some point.
2017-05-06 18:40:39 +01:00
5b59ca3c41 Add unit test for IniFile and improve parser.
The test still fails because for some reason the parser
doesn't want to skip the trailing spaces in values.
2017-05-06 02:01:05 +01:00
b4291becf0 Add unit test for the SettingsBag. 2017-05-05 09:48:46 +01:00
e1687c96ff Split tawashi into lib+executable to enable unit testing 2017-05-04 19:52:18 +01:00
bcb800ffef Buildfix in release 2017-05-04 19:41:18 +01:00
7646a04c51 Add user agent cgi variable. 2017-05-04 10:22:43 +01:00
c41e7ce65f Add more logging 2017-05-04 10:00:49 +01:00
92d8f1f73c Make logging level configurable in tawashi.ini. 2017-05-04 09:59:49 +01:00
c892ed2df8 Add logging lib spdlog. 2017-05-03 09:31:41 +01:00
73323c9ee7 Add plain text mode 2017-04-27 09:33:47 +01:00
457127aa04 Rename built binary to tawashi.cgi
Also copy html dir when doing make install.
2017-04-26 20:52:52 +01:00
4a57181ff6 Version bump to v0.1.3 2017-04-26 20:15:13 +01:00
3191203bfd Tell the browser returned plain text is utf8. 2017-04-26 20:12:59 +01:00
fbc9afc81c Remove invalid utf8 sequences from GET and POST. 2017-04-26 20:12:59 +01:00
f2bee62f0e Add utfcpp 2.3.4 to the project. 2017-04-26 20:02:49 +01:00
5377d25c72 Simplify the response pipeline.
There is no on_send() anymore, instead responses can
override the way the top-level mustache file is retrieved.
2017-04-26 09:17:57 +01:00
298aedc633 Version bump to v0.1.2 2017-04-25 22:56:35 +01:00
06920f8d84 Return pasties into a proper html page.
I don't think html escaping is needed, since pasties
go through the colorizer first.

I don't really like the workaround to not call on_send() when
I don't want the html output, it's a bit omg what's going on
there... I'll have to rewrite that bit.
2017-04-25 22:56:19 +01:00
54e737c171 Escape html in non-plaintext responses. 2017-04-25 22:09:46 +01:00
8a23dc1add An empty GET is synonym of m=plain 2017-04-25 22:09:46 +01:00
85784d231d Use houdini escaping instead of easy_curl.
Drop dependency on easy_curl.
2017-04-25 22:09:46 +01:00
c75c23fa36 Import houdini lib.
Will replace curl dependency soon.
2017-04-25 22:09:45 +01:00
b423522af8 Enable language and expiry in pasties. 2017-04-25 00:21:44 +01:00
9232644cbb I missed this in a previous commit - take the setting from the SettingsBag. 2017-04-25 00:10:50 +01:00
3e60ea4183 Escape any html from pasties before sending the response. 2017-04-24 19:41:38 +01:00
3c10d624e3 Allow users to specify min/max valid pastie sizes. 2017-04-24 19:09:43 +01:00
79e82e2489 Do the str to int conversion in the SettingsBag. 2017-04-24 18:55:04 +01:00
fe53ea7ea1 Implement as_str() and as_ref() as template as<>().
Also provide a commodity at() that is a synonym
for as<boost::string_ref>() but much shorter to type.
2017-04-24 09:25:04 +01:00
34e69d0b52 Version bump to 0.1.1 2017-04-23 15:06:36 +01:00
eebcfb4157 Set default html path to "", not "html". 2017-04-23 13:58:06 +01:00
0add0720d5 Add langmap_dir setting.
Allows users to specify the path to the langmap dir for
source-highlight.
2017-04-23 13:57:49 +01:00