Commit Graph

3349 Commits (23dd1e0c0afb062b8570da3782f3c01a530725f4)

Author SHA1 Message Date
Joey Hess 68e2320696
inline: Prevent creating a file named ".mdwn" when the postform is submitted with an empty title. 2016-09-21 13:51:42 -04:00
Amitai Schlair 85c10d149b Update my surname to its new legal spelling. 2016-09-14 14:28:01 -04:00
Simon McVittie 276f0cf578 Use git log --no-renames for recentchanges
Otherwise, recent git releases show renames as renames, and we do not
see that newdir/test5 was affected.

Bug-Debian: https://bugs.debian.org/835612
2016-09-03 23:47:06 +01:00
Joey Hess d9bfe760d1
improve warning message for multiple sources for page 2016-05-31 15:29:09 -04: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
Amitai Schlair 89af9ecc57 Detect image type from .JPG just like .jpg (etc.). 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
Simon McVittie 125461cab7 inline: expand show=N backwards compatibility to negative N
[[plugins/contrib]] uses show=-1 to show the post-creation widget
without actually inlining anything.
2016-05-06 22:51:02 +01:00
Simon McVittie 984ba82f1b img: Add back support for SVG images, bypassing ImageMagick and simply passing the SVG through to the browser
SVG scaling by img directives has subtly changed; where before size=wxh
would preserve aspect ratio, this cannot be done when passing them through
and so specifying both a width and height can change the SVG's aspect
ratio.

(This patch looks significantly more complex than it was, because a large
block of code had to be indented.)

[smcv: drop trailing whitespace, fix some spelling]
2016-05-06 06:57:12 +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
Simon McVittie 54a9f8d07d img: force common Web formats to be interpreted according to extension
A site administrator might unwisely set allowed_attachments to
something like '*.jpg or *.png'; if they do, an attacker could attach,
for example, a SVG file named attachment.jpg.

This mitigates CVE-2016-3714.
2016-05-05 23:43:50 +01:00
Simon McVittie 32ef584dc5 HTML-escape error messages (OVE-20160505-0012)
The instance in cgierror() is a potential cross-site scripting attack,
because an attacker could conceivably cause some module to raise an
exception that includes attacker-supplied HTML in its message, for
example via a crafted filename. (OVE-20160505-0012)

The instances in preprocess() is just correctness. It is not a
cross-site scripting attack, because an attacker could equally well
write the desired HTML themselves; the sanitize hook is what
protects us from cross-site scripting here.
2016-05-05 23:43:17 +01:00
Florian Wagner bbdba8d770
Correctly handle filenames starting with a dash in add/rm/mv. 2016-03-17 11:01:27 -04:00
Amitai Schlair 63fa0ef5ba Process .md like .mdwn, but disallow web creation. 2016-03-08 14:31:15 -05:00
Joey Hess 8d28f70b37
loginselector: When only openid and emailauth are enabled, but passwordauth is not, avoid showing a "Other" box which opens an empty form. 2016-03-02 16:35:16 -04:00
Amitai Schlair f93544db76 Fix typo. 2016-02-20 22:00: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 855b757f37 Force comments URL in RSS feeds to be absolute
Now I'm going to get bug reports about wanting the URLs to be
protocol-relative, but we can't win there as long as we generate RSS,
because RSS doesn't have well-defined semantics for relative URLs
(and the W3C's validator complains about them). If absolute URLs are
a problem for you, please use Atom feeds.
2016-01-21 07:50:13 +00:00
Simon McVittie 317d19842c Silence "used only once: possible typo" warnings for variables that are part of modules' APIs 2016-01-19 11:24:18 +00:00
Simon McVittie 72c3b81efb Merge remote-tracking branch 'smcv/pagestats-show' 2015-11-30 20:58:54 +00:00
Simon McVittie b199349ffd Merge remote-tracking branch 'smcv/ready/limit' 2015-11-30 20:55:34 +00:00
Simon McVittie 1f635c6dca ensure_committer: don't do anything if we have the environment variables 2015-11-30 20:46:58 +00:00
Simon McVittie 8550c39701 Don't memoize ensure_committer
This makes it harder to test, and if we're invoking git anyway,
a couple of extra subprocesses are no big deal.
2015-11-30 20:46:58 +00:00
Simon McVittie ed1e1ebe70 git: if no committer identity is known, set it to "IkiWiki <ikiwiki.info>" in .git/config
This resolves commit errors in versions of git that require a non-trivial
committer identity.
2015-11-30 19:34:04 +00:00
Joey Hess 32923e732b emailauth: Added emailauth_sender config. 2015-10-02 11:49:47 -04:00
Amitai Schlair 09916a90ed Fix [[!meta name=foo]] by closing the open quote. 2015-08-22 22:34:53 -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 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 f2365c3e66 inline: change default sort order from age to "age title" for determinism 2015-06-13 19:58:37 +01:00
Simon McVittie 014b9eb1b7 polygen: if deterministic build is requested, use a well-known random seed 2015-06-09 22:30:44 +01:00
Simon McVittie 361076e55d haiku: if deterministic build is requested, return a hard-coded haiku 2015-06-09 22:30:43 +01:00
Simon McVittie 6add4fd4fc Sort backlinks deterministically, by falling back to sorting by href if the link text is identical 2015-06-09 22:30:43 +01:00
Simon McVittie 8e007666d4 brokenlinks: sort the pages that link to the missing page, for better reproducibility 2015-06-09 22:28:31 +01:00
Simon McVittie 2fe003dac4 Populate pagectime from mtime or inode change time, whichever is older
When building ikiwiki from a tarball, the mtime (conceptually, the
last modification date of the file) is preserved by tar, but the inode
change time (creation/metadata-change date of *this copy* of the file)
is not. This seems to lead to unstable sort ordering and
unreproducible builds.

The page can't possibly have been modified before it was created, so
we can assume that the modification date is an upper bound for the
creation date.
2015-06-09 22:22:54 +01:00
Simon McVittie f00ccd0bf6 In rebuilds, assume that every page has been scanned by the time the scan phase ends
This doesn't prevent memory from being used to track what we have
and haven't scanned, but it does make it temporary.

This only applies to rebuilds, as a way to avoid breaking the
templatebody plugin, unlike the earlier version of this optimization.
2015-06-09 00:14:57 +01:00
Simon McVittie 5fd863b5b0 Revert "Assume that every page has been scanned by the time the scan phase ends"
This reverts commit c04a26f3e7, which
turns out to break the templatebody directive: readtemplate() relies
on scan() populating %templates, but if scan() is a no-op after
leaving the scan phase, we can't rely on that.

The assumption made by skipping scan() after the end of the render phase
is that everything that comes from a scan is already in the index.
However, we don't really want to put template bodies in the index:
that would force us to load and save them on every refresh, and
redundantly persist them to disk.

Test-case:

% make clean
% ./Makefile.PL
% make
% grep -E '<div class="notebox">|Use this template to' html/sandbox.html
% touch doc/sandbox/New_blog_entry.mdwn          # sandbox inlines this
% make
% grep -E '<div class="notebox">|Use this template to' html/sandbox.html

Good result: html/sandbox.html contains <div class="notebox"> both times

Bad result: html/sandbox.html contains "Use this template to..." the
second time
2015-06-08 23:47:14 +01:00
Simon McVittie 7a52c87a8c Make the attachment plugin work with CGI.pm 4.x (Closes: #786586; workaround for #786587 in libcgi-pm-perl) 2015-06-07 14:51:13 +01:00
Simon McVittie 2afb0dd663 Do not directly enable emailauth by default, only indirectly via openid
This avoids nasty surprises on upgrade if a site is using httpauth,
or passwordauth with an account_creation_password, and relying on
only a select group of users being able to edit the site. We can revisit
this for ikiwiki 4.
2015-05-27 08:52:01 +01:00
Joey Hess 3676ab329d sohrten url in subject 2015-05-19 17:44:20 -04:00
Joey Hess ba02e7f33d nicer layout of subject 2015-05-19 17:41:14 -04:00
Joey Hess 73e32f7fa6 add url to subject of email
The wikiname can be pretty un-helpful, the user will probably regognise the
url since they were just at it.
2015-05-19 17:38:15 -04:00
Joey Hess ab1bba9dab cloak user PII when making commits etc, and let cloaked PII be used in banned_users
This was needed due to emailauth, but I've also wrapped all IP address
exposure in cloak(), although the function doesn't yet cloak IP addresses.

(One IP address I didn't cloak is the one that appears on the password
reset email template. That is expected to be the user's own IP address,
so ok to show it to them.)

Thanks to smcv for the pointer to
http://xmlns.com/foaf/spec/#term_mbox_sha1sum
2015-05-14 11:58:21 -04:00
Joey Hess 85a529db3d passwordauth: Don't allow registering accounts that look like openids.
Also prohibit @ in account names, in case the file regexp was relaxed to
allow it.
2015-05-14 10:57:56 -04:00
Joey Hess 70cf5bb765 don't let emailauth user's email address be changed on preferences page
There's no real problem if they do change it, except they may get confused
and expect to be able to log in with the changed email and get the same
user account.
2015-05-13 23:32:29 -04:00
Joey Hess 7a68c4a01c when an emailauth user posts a comment, use the username only, not the full email address
This makes the email not be displayed on the wiki, so spammers won't find
it there.

Note that the full email address is still put into the comment template.
The email is also used as the username of the git commit message
(when posting comments or page edits). May want to revisit this later.
2015-05-13 23:26:22 -04:00
Joey Hess 497513e737 avoid showing password prefs for emailauth user 2015-05-13 23:24:07 -04:00
Joey Hess 22339188e7 allow adminuser to be an email address 2015-05-13 23:07:29 -04:00
Joey Hess a7bd24b7b9 fix up session cookie 2015-05-13 23:06:52 -04:00
Joey Hess 95e1e51caa emailauth link sent and verified; user login works
Still some work to do since the user name is an email address and should
not be leaked.
2015-05-13 22:27:03 -04:00
Joey Hess 035c1a2449 move stub auth hook to loginselector 2015-05-13 18:54:13 -04:00
Joey Hess e34533d1a0 email auth plugin now works through email address entry 2015-05-13 18:50:40 -04:00
Joey Hess 5b459737a5 Converted openid-selector into a more generic loginselector helper plugin. 2015-05-13 18:50:29 -04:00
Joey Hess f8add0adb3 rename openid selector files to login-selector 2015-05-13 17:58:59 -04:00
Joey Hess 7765941011 further generalization of openid selector
Now template variables can be set to control which login methods are shown
2015-05-13 17:51:29 -04:00
Joey Hess ab4d9a5467 generalized the openid selector to a login selector
This includes some CSS changes to names of elements.

Also, added Email login button (doesn't work yet of course),
and brought back the small openid login buttons. Demoted yahoo and verison
to small buttons. This makes the big buttons be the main login types, and
the small buttons be provider-specific helpers.
2015-05-13 16:50:44 -04:00
Joey Hess ec72b4c95b When openid and passwordauth are the only enabled auth plugins, make the openid selector display "Password" instead of "Other", so users are more likely to click on it when they don't have an openid. 2015-05-13 12:18:22 -04: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
Anders Kaseorg f35c6a97d1 Fix double UTF-8 decode on Perl < 5.20 with upgraded Encode.pm
Commit feb21ebfac added a
safe_decode_utf8 function that avoids double decoding on Perl 5.20.
But the Perl behavior change actually happened in Encode.pm 2.53
(https://github.com/dankogai/p5-encode/pull/11).  Although Perl 5.20
is the first Perl version to bundle an affected version of Encode.pm,
it’s also possible to upgrade Encode.pm independently; for example,
Fedora 20 has Perl 5.18.4 with Encode.pm 2.54.  On such a system,
editing a non-ASCII file still fails with errors like

Error: Cannot decode string with wide characters at
/usr/lib64/perl5/vendor_perl/Encode.pm line 216.

There doesn’t seem to be any reason not to check Encode::is_utf8 on
old versions too, so just remove the version check altogether.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Bug-Debian: https://bugs.debian.org/776181
2015-03-01 12:43:20 +00:00
Joey Hess 6a46c2cf55 fix another unchecked malloc
<joeyh> any parrticular reason 12?
<igli> well maximum a 32-bit can go is 10 chars
<igli> so one for \0 and round up to 4
2015-01-25 00:10:34 -04:00
Joey Hess fe0eaf1870 Fix NULL ptr deref on ENOMOM in wrapper. (Thanks, igli)
Probably not exploitable, but who knows..
2015-01-25 00:00:40 -04:00
Amitai Schlair 3a19663d48 In VCS-committed anonymous comments, link to url. 2015-01-08 08:11:40 -05:00
Amitai Schlair 0451dc4133 Update blogspam to the 2.0 API. 2015-01-02 13:55:10 -05:00
Joey Hess f88e109bec po: If msgmerge falls over on a problem po file, print a warning message, but don't let this problem crash ikiwiki entirely. 2014-12-30 15:51:50 -04:00
Amitai Schlair a87f43d71e Avoid uninitialized warnings with comments+no CGI. 2014-12-28 13:15:45 -05:00
Amitai Schlair 38a088a433 ikiwiki-comment: optionally override parameters. 2014-12-27 22:38:18 -05:00
Amitai Schlair b87e46a76d Squelch "keys on reference is experimental". 2014-12-27 16:55:12 -05:00
Simon McVittie ceab72ad34 page.tmpl: tell mobile browsers we have a responsive layout, unless told not to
Mobile browsers typically assume that arbitrary web pages are
designed for a "desktop-sized" browser window (around 1000px)
and display that layout, zoomed out, in order to avoid breaking
naive designs that assume nobody will ever look at a website on
a phone or something. People who are actually doing "responsive
design" need to opt-in to mobile browsers rendering it at a
more normal size.
2014-12-01 21:29:46 +00:00
Simon McVittie 6c51b764bc Merge branch 'ready/html5' 2014-11-26 11:58:05 +00:00
Simon McVittie 1abf35e1b5 Fix numeric comparisons with undef 2014-11-26 11:29:14 +00:00
Simon McVittie 36f5e63d73 fix some typos 2014-11-26 09:23:24 +00:00
Simon McVittie 96566c33a7 Merge remote-tracking branch 'spalax/calendar-autocreate' 2014-11-26 09:13:44 +00:00
Louis 473bcbe7a4 Corrected error: month pages were created even without calendar_autocreate config option 2014-11-14 14:59:58 +01:00
Louis d0b3495124 Deleted unnecessary code 2014-11-14 12:52:51 +01:00
Louis 1d97160dae Indentation 2014-11-14 12:50:17 +01:00
Joey Hess ea8c7a7e02 openid: Stop suppressing the email field on the Preferences page.
This is needed for notifyemail, and not all openid providers report an
email address, or necessarily the one the user wants to get email.
2014-11-06 15:00:09 -04:00
Joey Hess 82a4fb49ae add ikiwiki-comment program 2014-10-20 12:08:07 -04:00
Amitai Schlair 305c91ccfb Remove space from perl shebang path. 2014-10-17 09:05:00 -04:00
Amitai Schlair 09e7c1ad99 IkiWiki::Plugin::openid: as a precaution, do not call non-coderefs
We're running under "use strict" here, so if CGI->param's array-context
misbehaviour passes an extra non-ref parameter, it shouldn't be executed
anyway... but it's as well to be safe.

[commit message added by smcv]
2014-10-16 22:24:48 +01:00
Amitai Schlair cfbcbda0ad Call CGI->param_fetch instead of CGI->param in array context
CGI->param has the misfeature that it is context-sensitive, and in
particular can expand to more than one scalar in function calls.
This led to a security vulnerability in Bugzilla, and recent versions
of CGI.pm will warn when it is used in this way.

In the situations where we do want to cope with more than one parameter
of the same name, CGI->param_fetch (which always returns an
array-reference) makes the intention clearer.

[commit message added by smcv]
2014-10-16 22:24:47 +01:00
Simon McVittie f4ec7b06d9 Make sure we do not pass multiple CGI parameters in function calls
When CGI->param is called in list context, such as in function
parameters, it expands to all the potentially multiple values
of the parameter: for instance, if we parse query string a=b&a=c&d=e
and call func($cgi->param('a')), that's equivalent to func('b', 'c').
Most of the functions we're calling do not expect that.

I do not believe this is an exploitable security vulnerability in
ikiwiki, but it was exploitable in Bugzilla.
2014-10-16 22:24:47 +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
Simon McVittie 17fccbca94 Do not pass ignored sid parameter to checksessionexpiry
checksessionexpiry's signature changed from
(CGI::Session, CGI->param('sid')) to (CGI, CGI::Session) in commit
985b229b, but editpage still passed the sid as a useless third
parameter, and this was later cargo-culted into remove, rename and
recentchanges.
2014-10-12 18:03:57 +01:00
Simon McVittie 4e2bfe1e17 comments: don't log remote IP address for signed-in users
The intention was that signed-in users (for instance via httpauth,
passwordauth or openid) are already adequately identified, but
there's nothing to indicate who an anonymous commenter is unless
their IP address is recorded.
2014-10-12 18:03:28 +01: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 b0a35c817e Force use of $config{url} as top URL in w3mmode 2014-10-05 15:19:55 +01:00
Joey Hess 6294894f31 Fix crash that can occur when only_committed_changes is set and a file is deleted from the underlay.
srcfile_stat got called on a file from the underlay that no longer existed.

I am not 100% sure of the circumstances of that; I was able to reproduce
the bug but neglected to snapshot the tree, and then accidentially
got it to stop crashing. I know that a transient tag page got deleted using
the web interface to trigger the crash.

It seems that process_changed_files must have returned the file, despite it
being deleted. And since the file was not checked into git, it seems it
must have not been included in @IkiWiki::underlayfiles, which would have
caused process_changed_files to not return it.

I do not know why a transient tag page would not be in
@IkiWiki::underlayfiles. There is a bug here that I don't understand.

This is just a workaround -- run srcfile_stat such that it won't crash,
and if it is unable to stat a file, find_changed knows it's not changed,
so it's ok to skip it.

Also made find_new_files run srcfile_stat such that it won't crash, just
because I was there.
2014-09-26 18:55:09 -04:00
Simon McVittie eb4945a3bc img: raise an error if we cannot find the image's size
This happens for PDFs without ghostscript installed, for instance.
2014-09-16 10:00:40 +01: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 ea2ab6f885 Merge branch 'ready/more-magic' 2014-09-15 21:08:40 +01:00
Simon McVittie 9d928bd694 Merge remote-tracking branch 'jcflack/early-env' 2014-09-15 09:44:51 +01:00
Lafayette Chamber Singers Webmaster 29e80b4eed More cautious escaping of environment values.
Tightened the escaping per this review comment:
http://source.ikiwiki.branchable.com/?p=source.git;a=commitdiff;h=f35fc6a603b5473ce2c07bb0236e28e57f718315

(I didn't introduce a $tmp, as $val was local to that block already, and each
hex encoding is in its own C string literal to avoid consuming subsequent
chars that are valid hex digits.)
2014-09-14 20:07:43 -04:00
Lafayette Chamber Singers Webmaster bc4721da04 Installing ikiwiki on a shared-hosting server, there may be no access to
install prerequisite Perl modules in the systemwide locations. They may
have to be installed under the home directory, such as by using local::lib
(which is how the cPanel Perl-module installer works, on systems that use it).

For that to work, the local::lib-defined value for PERL5LIB must be in
the environment when Perl starts up. The former way %config{ENV} was handled
was too late, depending on the Perl code to unpack it from the storable and
put it into the environment.

Easy solution is to build the wrapper to repopulate the environment based on
%config{ENV} before ever exec'ing Perl (and then remove it from the storable
as there is nothing more that the Perl code will need to do with it).
2014-09-14 12:12:09 -04:00
Simon McVittie e3e6ca2777 pagestats: rename disp to show, and document it 2014-09-14 15:57:09 +01:00
Simon McVittie 89492a62a7 pagestats: consistent indentation 2014-09-14 15:51:22 +01:00
Louis cd5a24d8b4 pagestats: add disp parameter 2014-09-14 15:49:38 +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