Commit Graph

510 Commits (43a88daa5fc23fb70c22ab4472dd293e04b7236d)

Author SHA1 Message Date
Simon McVittie 4729ff0812 Exclude working directory from library path (CVE-2016-1238)
Current Perl versions put '.' at the end of the library search path
@INC, although this will be fixed in a future Perl release. This means
that when software loads an optionally-present module, it will be
looked for in the current working directory before giving up. An
attacker could use this to execute arbitrary Perl code from ikiwiki's
current working directory.

Removing '.' from the library search path in Perl is the correct
fix for this vulnerability, but is not trivial to do due to
backwards-compatibility concerns. Mitigate this (even if ikiwiki is run
with a vulnerable Perl version) by explicitly removing '.' from the
search path, and instead looking for ikiwiki's own modules relative
to the absolute path of the executable when run from the source
directory.

In tests that specifically want to use the current working directory,
use "-I".getcwd instead of "-I." so we use its absolute path, which
is immune to the removal of ".".
2016-07-28 09:50:21 +01:00
Simon McVittie 5f6f9a1bea Wrapper: allocate new environment dynamically
Otherwise, if third-party plugins extend newenviron by more than
3 entries, we could overflow the array. It seems unlikely that any
third-party plugin manipulates newenviron in practice, so this
is mostly theoretical. Just in case, I have deliberately avoided
using "i" as the variable name, so that any third-party plugin
that was manipulating newenviron directly will now result in the
wrapper failing to compile.

I have not assumed that realloc(NULL, ...) works as an equivalent of
malloc(...), in case there are still operating systems where that
doesn't work.
2016-05-11 09:18:14 +01:00
Simon McVittie 6879e37828 img test: exercise upper-case extensions for image files 2016-05-09 21:53:10 +01:00
Amitai Schlair e24e6fed62 Fix spelling of "ratio" in test. 2016-05-08 18:31:02 -04:00
Simon McVittie 47b180e35f img: make img_allowed_formats case-insensitive 2016-05-07 23:22:52 +01:00
Joey Hess 21b9b9e306 update test suite for svg passthrough by img directive
Remove build dependency libmagickcore-6.q16-2-extra which was only there
for this test.
2016-05-06 06:58:56 +01:00
Simon McVittie 170cd41489 img: check magic number before giving common formats to ImageMagick
This mitigates CVE-2016-3714 and similar vulnerabilities by
avoiding passing obviously-wrong input to ImageMagick decoders.
2016-05-05 23:43:50 +01:00
Simon McVittie 545a7bbbf0 img: restrict to JPEG, PNG and GIF images by default
This mitigates CVE-2016-3714. Wiki administrators who know that they
have prevented arbitrary code execution via other formats can re-enable
the other formats if desired.
2016-05-05 23:43:50 +01:00
Amitai Schlair b4222955b4 Fix CVS tests by uninverting $installed (cdfb4ab). 2016-02-18 23:25:54 -05:00
Simon McVittie 7aca0d40a3 Compose relative URLs in RSS feeds correctly
If the relative link from the (page generating the) RSS to the target
would start with "./" or "../", just concatenating it with the URL to
the directory containing the RSS is not sufficient. Go via
URI::new_abs to fix this.
2016-01-21 08:40:14 +00:00
Simon McVittie 02a1aa4e49 Don't fail to syslog if the wiki name contains %s
This is a corner case spotted while fixing UTF-8 syslogging.
2016-01-21 07:33:41 +00:00
Simon McVittie b8dbb48fdc Force log messages to be bytestrings
Sys::Syslog is not UTF-8-literate.
2016-01-21 07:33:41 +00:00
Simon McVittie b0627aef10 img test: use the right filenames when testing that deletion occurs
Also use a less misleading name for the sample SVG: it is no longer empty.
Since commit 105f285a it has contained a blue square.
2016-01-19 11:24:18 +00:00
Simon McVittie 5dceeb28d8 img test: skip testing PDFs if unsupported 2016-01-19 11:24:18 +00:00
Simon McVittie b199349ffd Merge remote-tracking branch 'smcv/ready/limit' 2015-11-30 20:55:34 +00:00
Simon McVittie 67906ded04 Add a test for unconfigured git identity 2015-11-30 20:46:58 +00:00
Simon McVittie d90002b8d7 tests: consistently use done_testing instead of no_plan 2015-11-30 18:26:23 +00:00
Simon McVittie 6b322448ca t/img.t: do not spuriously skip 2015-11-30 18:26:23 +00:00
Simon McVittie cdfb4ab1a3 Run autopkgtest tests using autodep8 and the pkg-perl team's infrastructure 2015-11-30 18:26:22 +00:00
Amitai Schlair 09916a90ed Fix [[!meta name=foo]] by closing the open quote. 2015-08-22 22:34:53 -04:00
Amitai Schlair 69f8b6427e Sans ImageMagick, bail gracefully. 2015-08-22 21:50:38 -04:00
Amitai Schlair 7f76e0ccc1 Mark a few straggling test scripts +x. 2015-08-18 07:31:29 -04:00
Amitai Schlair d42ed9bdc3 Test many behaviors of the meta directive. 2015-08-15 23:37:43 -04:00
Amitai Schlair 604d0391ba Squelch regex deprecation warnings from Perl 5.22.
Specifically:

"Unescaped left brace in regex is deprecated, passed through in regex"
2015-06-14 21:35:51 -04:00
Simon McVittie 841a86a4f3 img test: set old timestamp on source file that will change
This is so that the test will pass even if it takes less than 1 second.
2015-06-14 18:13:17 +01:00
Simon McVittie 7a2117bf8c img: stop ImageMagick trying to be clever if filenames contain a colon
$im->Read() takes a filename-like argument with several sets of special
syntax. Most of the possible metacharacters are escaped by the
default `wiki_file_chars` (and in any case not particularly disruptive),
but the colon ":" is not.

It seems the way to force ImageMagick to treat colons within the
filename as literal is to prepend a colon, so do that.
2015-06-13 20:00:08 +01:00
Simon McVittie 9497fc1b6c t/inline.t: accept translations of "Add a new post titled:" (Closes: #779365) 2015-03-01 17:15:13 +00:00
Simon McVittie a1fda0b516 Standardize on --long-option instead of -long-option
[[forum/refresh_and_setup]] indicates some confusion between --setup
and -setup. Both work, but it's clearer if we stick to one in
documentation and code.

A 2012 commit to [[plugins/theme]] claims that "-setup" is required
and "--setup" won't work, but I cannot find any evidence in ikiwiki's
source code that this has ever been the case.
2015-03-01 16:15:01 +00:00
Simon McVittie 6b6d330bad textile-double-escape-bug.t: tolerate any valid encoding
Discount in current Debian unstable turns the IURI href into a URI
by encoding the Unicode as UTF-8 and %-escaping each byte.
That is valid, and matches Wikipedia's expectations, but was breaking
this test for me.

It would also be entirely valid (and lead to equivalent parsing) if the
ö was represented as ö, ö or &#xf6 in the text and/or the href.
2015-01-06 00:28:18 +00:00
Simon McVittie 4315581f31 Turn positive test for wrong behaviour into a TODO test for right behaviour
We don't want ikiwiki's tests to stop passing when
Text::Textile is fixed.
2015-01-06 00:28:18 +00:00
Amitai Schlair 97f8b33c1a Document an annoying Text::Textile encoding bug. 2014-12-22 22:43:40 -05:00
Simon McVittie b9596b2049 Add regression test for libdir/libdirs 2014-12-09 22:54:26 +00:00
Simon McVittie 6c51b764bc Merge branch 'ready/html5' 2014-11-26 11:58:05 +00:00
Simon McVittie 105f285a63 Work around Debian #771047: use a non-blank SVG for the regression test
Inkscape loses the bounding box of a SVG with no content when it
converts it to EPS, and ImageMagick does not have a special case for
converting SVG to PNG with Inkscape in one step (which Inkscape can do);
it prefers to convert SVG to EPS with Inkscape, then EPS to whatever.
2014-11-26 11:10:44 +00:00
Simon McVittie b679fc65f5 We no longer have a test for DTD-valid XHTML 1.0, but at least check well-formedness
This means that people can do XSLT nonsense if they want to.

The failures are currently marked TODO because not everything in the
docwiki is in fact well-formed.
2014-10-16 11:25:10 +01:00
Simon McVittie fb7225dbe6 Remove now-redundant test-cases for a non-default html5 setting 2014-10-16 11:08:01 +01:00
Simon McVittie a052771287 Now that we're always using HTML5, <base href> can be relative 2014-10-16 11:05:19 +01:00
Simon McVittie 490a1eca7b Always produce HTML5 doctype and new attributes, but not new elements
According to caniuse.com, a significant fraction of Web users are
still using Internet Explorer versions that do not support HTML5
sectioning elements. However, claiming we're XHTML 1.0 Strict
means we can't use features invented in the last 12 years, even if
they degrade gracefully in older browsers (like the role and placeholder
attributes).

This means our output is no longer valid according to any particular
DTD. Real browsers and other non-validator user-agents have never
cared about DTD compliance anyway, so I don't think this is a real loss.
2014-10-16 11:04:53 +01:00
Amitai Schlair 47fff754c8 Extract test subs for each site. No change meant. 2014-10-12 09:30:31 -04:00
Amitai Schlair 508457fc05 Extract run_cgi(). No functional change intended. 2014-10-12 00:01:09 -04:00
Amitai Schlair 0db1679a3d Extract check_generated_content(). Same output. 2014-10-11 09:52:21 -04:00
Amitai Schlair dc872e42c8 Extract check_cgi_mode_bits(). No change intended. 2014-10-10 21:17:39 -04:00
Amitai Schlair cd9297322a Extract thoroughly_rebuild(), a slight test change.
I didn't try to parameterize when a test should fail when we can't
remove ikiwiki.cgi because there already isn't one. (Hooray, natural
language.) Instead, we stop worrying about it and always tolerate
ENOENT.
2014-10-10 20:40:24 -04:00
Amitai Schlair 7d82570fe0 Extract write_setup_file(). No functional change.
Test output differs only by the line numbers of the TODO items.
2014-10-10 20:25:54 -04:00
Amitai Schlair bb8f15e2a7 simplify IPC::Run check (same behavior) 2014-10-06 16:31:52 -04:00
Simon McVittie 33f60260b2 In html5 mode, generate a host- or protocol-relative <base> for the CGI
This increases the number of situations in which we do the right thing.
2014-10-05 23:49:37 +01:00
Simon McVittie 3b8da667cc Add reverse_proxy option which hard-codes cgiurl in CGI output
This solves several people's issues with the CGI trying to be
too clever when IkiWiki is placed behind a reverse-proxy.
2014-10-05 23:49:37 +01:00
Simon McVittie d712389ae3 Avoid mixed content when cgiurl is https but url is not 2014-10-05 23:49:37 +01:00
Simon McVittie 532f7adfdb Use protocol-relative URIs if cgiurl and url differ only by authority (hostname) 2014-10-05 15:56:19 +01:00
Simon McVittie fe9e94513a Fix a test-case that actually just repeated the previous one instead 2014-10-05 15:49:20 +01:00
Simon McVittie b0a35c817e Force use of $config{url} as top URL in w3mmode 2014-10-05 15:19:55 +01:00
Simon McVittie 210bf742b9 relative URLs test: pass an appropriate PERL5LIB through
We were previously using the system copy of IkiWiki, because the CGI
resets its environment.
2014-10-05 15:19:12 +01:00
Simon McVittie 823268e5c7 add the beginnings of a test for CGI/static URL interactions 2014-10-05 14:29:32 +01:00
Amitai Schlair afd9b2ff74 Search $PATH for "validate", since the test does.
"validate" is a very generic command name, and it validates against
an old standard, so the value of this test is questionable.
2014-10-01 15:06:24 -04:00
Simon McVittie 526a463ae5 img test: skip SVG tests if unsupported by Image::Magick 2014-09-16 10:00:27 +01:00
Amitai Schlair 04a10a180d Pass -templatedir to get this test passing again. 2014-09-15 22:16:39 -04:00
Simon McVittie 7f5c2cfa5a Merge branch 'ready/templatebody' 2014-09-15 21:52:03 +01:00
Simon McVittie c1b80c54fa Merge branch 'ready/autoindex-more-often' 2014-09-15 21:23:18 +01:00
Simon McVittie 0490ead761 extend rst test to cover a fixed bug 2014-09-14 15:47:42 +01:00
Simon McVittie ab768a62c6 Rename show parameter of [[!inline]] and [[!pagestats]] to limit
The old name still works, if its value is numeric.

This name allows a non-numeric "show" to mean the same thing
it does for [[!map]] (show title, show description, etc.).
2014-09-14 15:15:27 +01:00
Simon McVittie 43367c5e30 extend regression test for inline to cover inlining, show, reverse 2014-09-14 15:14:42 +01:00
Simon McVittie 9be3f95116 Merge branch 'ready/imgforpdf-and-more' 2014-09-12 21:59:00 +01:00
Simon McVittie d55d06ea88 use readfile() instead of reinventing it
This avoids potential action-at-a-distance from locally redefining $/
but never reaching the end of the redefinition's scope.
2014-09-01 08:40:54 +01:00
chrysn 0f9ea1f720 unit test for bugs/image_rescaling_distorts_with_small_pictures 2014-07-15 14:03:31 +02:00
chrysn a0a26d24f9 make img unittest easier to debug 2014-07-15 14:03:00 +02:00
chrysn a308b212ad img plugin: split resizing calculations and actual resizing
there is now a size calculating part (which chooses a final size) and a
scaling part (which triggers if the sizes calculated by the former
indicate a downscaling).

this solves the issue of unproportional upscalings
(bugs/image_rescaling_distorts_with_small_pictures).

also, "small" pdf files (or pdf files without explicit size settings),
which would not be converted under the old mechanism, now get rendered
to pngs.

this commit affects a unit test: while svgs were previously
unconditionally rendered to pngs, this now only happens on downscaling.
this is intentional -- while a small version of an svg graphic is
likely to be more compact when rendered (eg as a preview), a large
version would not have that benefit, and why convert something that
browsers basically can show and be inconsistend with how other images
are handled. the new unit test simply makes the original svg larger to
check for the same behaviros as before.
2014-07-15 13:44:22 +02:00
Simon McVittie 0357ad66ea inline: postform=no should take precedence over rootpage existing
If someone has explicitly disabled the postform, it seems reasonable
from a least-astonishment point of view for that to take precedence
over rootpage, even though that makes rootpage useless.

Also add a regression test; so far, this is all it tests.
2014-07-04 23:23:42 +01:00
chrysn 536a3364b2 drop unittest workaround for new perlmagick
just install -extra to make it work
2014-07-04 22:32:36 +02:00
chrysn c3019d94c6 drop unittest workaround for perlmagick
this was actually http://bugs.debian.org/753770
2014-07-04 22:32:24 +02:00
chrysn f9963b97c2 make unittest work with all all three packages that provide perlmagick 2014-07-04 22:32:13 +02:00
chrysn 4bd25423ac add unittests for img
this focuses on the features introduced in
http://ikiwiki.info/bugs/svg_and_pdf_conversion_fails/
2014-07-04 15:16:07 +02:00
Simon McVittie 17440ea301 Allow creation of transient index pages for directories outside srcdir
After this change autoindex creates index pages also for empty directories
included in underlays, but only if it isn't going to commit them to the
srcdir ($config{autoindex_commit} = 0).

Inspired by a patch from Tuomas Jormola.

Bug-Debian: http://bugs.debian.org/611068
2014-07-04 09:25:09 +01:00
Simon McVittie fefc8f4dce Add a regression test for autoindex_commit => 1 2014-07-04 09:22:57 +01:00
Simon McVittie 532d05be9e autoindex test: check what happens to files in transient/normal underlays 2014-07-04 09:22:57 +01:00
Joey Hess 811b477c35 fix test case ogg mime type
Seems that a better mime type is detected now on Debian stable.
2014-06-13 10:25:27 -04:00
Simon McVittie 7672014582 Add templatebody plugin and directive, and enable it by default
Also add a regression test for templatebody.
2014-03-05 10:42:19 +00:00
Joey Hess e1a0b25be1 Merge remote-tracking branch 'remotes/smcv/ready/template-syntax-test' 2014-02-23 14:31:51 -04:00
Joey Hess 204dcda88b Merge remote-tracking branch 'intrigeri/fix_diffurl_vs._cgit' 2014-02-23 14:13:53 -04:00
Joey Hess c5d63c549d Merge remote-tracking branch 'anarcat/dev/syslog_utf8' 2014-02-23 14:09:51 -04:00
Simon McVittie 9de5ca411f template_syntax.t: include doc/templates/*.mdwn in test
Previously, this test assigned the first glob to @templates, and
evaluated the second for its (practically nonexistent) side-effects.
2014-02-21 18:38:10 +00:00
Joey Hess 90ebe2e57d avoid running this test if File:MimeInfo is not installed
it's needed to get mime types in the feed
2014-01-25 17:08:22 -04:00
intrigeri d52774dd45 Do not UTF8-escape "/" in Git's diffurl: cgit does not support this. 2013-12-31 01:47:10 +00:00
Antoine Beaupré 2a143bfd0b don't edit config setting, but a temporary variable, complete and unbreak tests 2013-11-29 01:09:04 -05:00
Antoine Beaupré 9293d2c706 failing test case 2013-11-29 01:09:04 -05:00
Joey Hess fae7ed1429 remove test for page state saved for disabled plugin
My change did cause this state to be retained. I hope this is not a
problem.

Afaik, plugins test if they were disabled before by looking at the toplevel
plugin state, not the per-page plugin state. So the only remaining problem
might be

a) A plugin is disabled but its state keeps being saved. Which is not
   ideal, perhaps, but the large speedup of my optimisation seems worth it.
b) A plugin might have been enabled, be disabled, and get re-enabled, and
   see old state from before. I don't see how this would be different from
   the plugin seeing any other old state, though, so hopefully no breakage.

My optmisation looks a little more risky, but I still hope I can keep it.
2013-11-16 12:43:46 -04:00
Joey Hess 8833cfe30d Fix test suite to work with perl 5.18. Closes: #719969 2013-08-30 22:43:02 -04:00
Amitai Schlair 0c320f45e8 Genericize download link for more use cases. 2013-06-26 20:21:33 -04:00
Amitai Schlair d33b31f706 Merge branch 'master' into fancypodcast 2013-05-12 19:16:50 -04:00
Joey Hess 5121198cb9 avoid running test if xml::twig is not installed 2013-05-09 10:46:25 -04:00
Amitai Schlair 137ed653ea Merge branch 'master' into fancypodcast
Conflicts:
	doc/todo/fancypodcast.mdwn
2013-03-17 15:01:13 -04:00
Simon McVittie 766a2c7ab1 permalink test: start by deleting t/tmp
Otherwise, tests that don't end by deleting t/tmp (which is a useful
change when debugging a failing test) would cause this one to fail.
2013-02-24 13:18:34 +00:00
Simon McVittie 2bdb0c5902 map test: clean up after ourselves 2013-02-24 13:16:13 +00:00
Simon McVittie 12ca01fd5c map test: print maps' source as comments 2013-02-24 13:10:24 +00:00
Simon McVittie 82537ecf19 extend test, some cases now fail 2013-02-24 13:10:24 +00:00
Simon McVittie 54a48e15d8 Add a test for the map directive 2013-02-24 13:10:24 +00:00
Amitai Schlair 2df57e9906 Un-copy-paste the fancy-podcast tests. 2013-02-21 23:12:15 -05:00
Amitai Schlair d77ee60b15 Render fancy podcast enclosures.
Simple podcast feeds didn't have content tags and I made sure to
keep it that way. This may be unnecessarily conservative. Changing
the behavior to include empty content tags might be fine, but I
don't want to think about it right now, I just want my tests to
keep passing!

The new fancy-podcast tests are copy-pasted-edited from the
simple-podcast tests. These tests shall be refactored.
2013-02-20 21:16:19 -05:00
Amitai Schlair 3d2be49420 Make enclosures absolute (in feeds they have to be). 2013-02-20 19:14:20 -05:00
Amitai Schlair a7a68417d0 When inlining HTML pages, render enclosures. 2013-02-19 20:22:47 -05:00
Amitai Schlair d27c587ec9 Let tests determine whether feeds get made. 2013-02-19 20:22:47 -05:00