Commit Graph

2687 Commits (master)

Author SHA1 Message Date
urosm d17225bd2f replace deprecated tt tags with code tags 2024-02-02 15:00:29 +01:00
Joey Hess 2c2934138c
git: Pass --no-rebase when pulling
To avoid git warning messages about pull.rebase.

I don't think it would make sense to want to rebase changes pulled from
origin when updating the checkout used to build a site. So it seems ok to
just use --no-rebase and not worry about honoring any pull.rebase setting.
2023-07-19 12:53:01 -04:00
Joey Hess 4a5cab56d0
hack to support media:content
This is ugly, but XML::Feed does not support the tag.
2022-08-29 19:14:17 -04:00
Joey Hess 7591cf7776
aggregate enclosures
aggregate: When a feed has an enclosure that is an image, audio, or video,
include the enclosure in the generated page.

The enclosure is hotlinked from the original feed, not copied.

My use case is to include a mastodon rss feed in amoung other rss feeds for
users who don't use mastodon. It could also be used to aggregate together
podcasts, etc.

Other enclosure types than image, audio, video, could be added, perhaps
a generic one? But these are the main ones.

The template uses 50% width for image and video, because often
attachments are in a high resolution, which will default to being
perhaps too wide for the page, or taking up a lot of vertical space. By
making it take up at most half the page width, that is avoided, while
also leaving room for any sidebar.

Sponsored-by: Shae Erisson on Patreon
2021-12-25 12:59:27 -04:00
Amitai Schleier 9ea3f9dfe7 Catch up to highlight 4.0 API change.
In 4.0, searchDataDir() is gone, replaced by initSearchDirectories().
Call the latter if available, else fall back to the former.
2021-05-14 08:46:53 +02:00
Amitai Schleier e642784901 Fix inverted footnote config with MultiMarkdown.
Bug spotted and fix from Giuseppe Bilotta <giuseppe.bilotta@gmail.com>.

Extend mdwn tests to cover MultiMarkdown, where applicable.
2019-09-04 19:01:28 -04:00
Amitai Schleier 4d06df9583 Catch up to highlight 3.51 API change.
As of 3.51, searchFile() is no longer provided in highlight's Perl
bindings (at least on NetBSD and OS X, as built from pkgsrc). This
leaves us falling through to getConfDir(), which has been gone
rather longer.

From highlight git, it appears searchFile() and getFiletypesConfPath()
both originated in the 3.14 release. The latter is still available in
3.51, and returns the same result searchFile() used to. Switch to it.
2019-05-26 23:45:19 -04:00
Simon McVittie d283e4ca1a useragent: Automatically choose whether to use LWPx::ParanoidAgent
The simple implementation of this, which I'd prefer to use, would be:
if we can import LWPx::ParanoidAgent, use it; otherwise, use
LWP::UserAgent.

However, aggregate has historically worked with proxies, and
LWPx::ParanoidAgent quite reasonably refuses to work with proxies
(because it can't know whether those proxies are going to do the same
filtering that LWPx::ParanoidAgent would).

Signed-off-by: Simon McVittie <smcv@debian.org>
2019-02-26 22:21:27 +00:00
Simon McVittie 824cf7db1b po: Always filter .po files
The input to filter hooks is meant to be the content of a source file
on disk. If we only filter once per (page, destpage) pair, and a page
is inlined into the same destpage more than once, then the second
occurrence will render as the result of htmlizing .po source as if
it was Markdown (or whatever the type of the corresponding master page
is), which is never going to end well.

The alreadyfiltered mechanism was added in commit 1e874b3f to avoid
preprocessing loops, but I'm not sure where it could lead to a loop:
filter hooks are only called from IkiWiki::filter, which is only called
on page content from disk or on proposed content being previewed.
According to <https://bugs.debian.org/911356#41>, deleting the
alreadyfiltered mechanism resolves the problem, as well as simplifying
the code.

Closes: #911356
Tested-by: intrigeri
2019-02-24 17:23:34 +00:00
Antoine Beaupré d16e34c736 append javascript after CSS
Javascript resources should be presented to browsers after CSS, and
"after the fold" (ATF) according to the best practices:

https://developers.google.com/speed/docs/insights/mobile#PutStylesBeforeScripts

This change allows the browser to download Javascript files in
parallel, by including Javascript on the *closing* </body> tag instead
of the opening tag.

We also improve the regex to tolerate spaces before the body tag, as
some templates have (proper) indentation for the tag.
2019-02-03 17:01:55 +00:00
Feng Shu e8dea1b924 Fix inline plugin for non-ASCII rootpage 2019-02-03 13:15:35 +00:00
Simon McVittie 15ddbb1c70 trail: Allow unescaped punctuation in pagenames
By processing the pagenames through linkpage, we let users specify
page names that contain non-alphanumerics in a more natural way.

Signed-off-by: Simon McVittie <smcv@debian.org>
2019-02-03 12:52:42 +00:00
Feng Shu 2965846ef2 Fix table plugin can handle UTF-8 csv format 2019-01-31 20:37:06 +00:00
Joey Hess 5d44bf4b5c
fix permalink to comments
This commit was sponsored by Thomas May.
2019-01-21 11:57:23 -04:00
Joey Hess 4f0b10c13d
rename postvote to postlink
This better explains what it contains, which is a wikilink to the page
to go to after posting the vote. And postlink is more consistent a name
with posttrail.
2018-11-26 13:23:50 -04:00
Joey Hess 97d921ca67
poll: Added postvote and posttrail options for better multi-page polls.
Modern web users probably expect the poll to move on automatically to the
next question, and this allows for that behavior.

Note that bestlink() runs at vote time, which avoids needing to make the
page containing the poll depend on the page that sets up a trail, as the
current trail at vote time will be used.

This commit was sponsored by Eric Drechsel on Patreon.
2018-11-26 13:14:21 -04:00
Joey Hess 0ec2c55ac0
aggregate: Fix aggregation of posts without a title
When an aggregated post lacked a title, the code first prepended the
$feed->{dir} to it, and only then checked if it had zero length. So,
that check could never succeed and it was possible to end up with
$page="dir/", and writing to that would of course fail.

(Same problem could also occur when the whole title got sanitized away by the
wiki_file_regexp.)

Fixed by simply checking earlier if $page is empty.

Based on a patch by Alexandre Oliva which got lost in a maze of email
folders all alike for over two years despite him mentioning it to me at
least once in person.
2018-10-28 19:00:32 -04:00
Amitai Schleier 9332b8115d Give graph an optional "file" param, like table's. 2018-10-22 00:24:59 -04:00
Amitai Schleier fb47d4a9d5 When emailauth can't send, show the error message. 2018-05-13 09:52:04 -04:00
Amitai Schleier ab9cb28414 Call srcfile() with nothrow, as clearly intended. 2018-04-23 22:28:49 -04:00
Simon McVittie 10dc1fa7b2 meta: Error if we can't parse dates because Date::Parse is missing
You can still use [[!meta name="date" content="..."]] to generate
<meta> tags that are not interpreted, but the common case for
[[!meta date="..."]] is that you want to change the ctime, and that
won't work without Date::Parse.

Signed-off-by: Simon McVittie <smcv@debian.org>
2018-03-21 09:33:04 +00:00
Simon McVittie 88c66d3758 meta: Make syntactically invalid dates an error
If for some reason you want to create <meta name="date" content="12345">,
this now requires [[!meta name="date" content="12345"]].

Signed-off-by: Simon McVittie <smcv@debian.org>
2018-03-21 09:33:04 +00:00
Simon McVittie e3279c8b50 mdwn: Automatically detect which libdiscount flags to use
Unconditionally passing arbitrary numbers as flags turns out to be a
bad idea, because some of the "unused" values have historically had
side-effects internal to libdiscount. Detect whether the known flags
work by rendering short Markdown snippets the first time we htmlize,
checking whether each known flag is both necessary and sufficient.

Signed-off-by: Simon McVittie <smcv@debian.org>
2018-03-08 23:36:31 +00:00
Simon McVittie 54095ea655 img: Explicitly detect format if needed
An empty coder name used to detect the format implicitly, but has been
interpreted as a literal part of the filename since ImageMagick 6.9.8-3.
In newer versions, there does not seem to be any way to indicate that
a filename containing ':' is to be taken literally without first
knowing the decoder to use.

Signed-off-by: Simon McVittie <smcv@debian.org>
2018-02-28 09:56:08 +00:00
Simon McVittie f46e429d96 mdwn: Restore historical behaviour
The Discount package in Debian historically enabled fenced code blocks,
PHP Markdown Extra-style definition lists, and an expanded character
set for tag names. Since Discount 2.2.0 those are runtime settings, so
enable them. Unfortunately Text::Markdown::Discount doesn't yet expose
the necessary constants:
https://rt.cpan.org/Public/Bug/Display.html?id=124188

The IDANCHOR option was historically also enabled in Debian, but is not
enabled here because ikiwiki does not enable the TOC option, and
IDANCHOR does nothing without TOC.

Closes: #888055
2018-01-29 22:35:29 +00:00
Joey Hess a79ab9ed18
add and use cgiurl_abs_samescheme
* emailauth: Fix cookie problem when user is on https and the cgiurl
   uses http, by making the emailed login link use https.
 * passwordauth: Use https for emailed password reset link when user
   is on https.

Not entirely happy with this approach, but I don't currently see a
better one.

I have not verified that the passwordauth change fixes any problem,
other than the user getting a http link when they were using https.
The emailauth problem is verified fixed by this commit.

This commit was sponsored by Michael Magin.
2018-01-05 11:59:35 -04:00
intrigeri 146f1d9ab5 img: resize images in a deterministic manner. 2017-09-01 19:26:26 +00:00
Joey Hess e3dfb26b90
emailauth, passwordauth: Avoid leaving cgisess_* files in the system temp directory.
Due to the use/abuse of CGI::Session to generate a token for the login
process, a new session database was created for each login, and left behind
afterwards. While each file is small, with many logings this could bloat
the size of /tmp significantly. Fixed by making CGI::Session write to
/dev/null, since there does not seem to be a way to entirely prevent the
writing.

This commit was sponsored by Henrik Riomar on Patreon.
2017-08-23 13:13:23 -04:00
Joey Hess f3beb9cb44
htmlscrubber: Add support for the video tag's loop and muted attributes.
Those were not in the original html5 spec, but have been added in the
whatwg html living standard and have wide browser support.

This commit was sponsored by John Peloquin on Patreon.
2017-07-11 15:51:44 -04:00
Simon McVittie 5a84cd308d osm: Convert savestate hook into a changes hook
savestate is not the right place to write wiki content, and in particular
this breaks websetup if osm's dependencies are not installed, even if
the osm plugin is not actually enabled. (Closes: #719913)

This is not a full solution: it should be possible to render the PoI files
for only the maps that changed, from the format, changes or rendered
hook. However, getting that right would require more understanding of
this plugin, and this version is enough to not break websetup. This
version is the closest correct hook to the one where this previously
took place.
2017-06-20 23:47:08 +01:00
Simon McVittie 01f2a84360 color: Use markup for the preserved CSS, not character data
This still smuggles it past the sanitize step, but avoids having
other plugins that want to capture text content without markup
(notably toc) see the CSS as if it was text content.
2017-05-16 12:08:55 +01:00
Antoine Beaupré b5b48d5bb5 use heading identifiers in TOC links
reasoning: if headings have identifiers, they are probably more useful
anchors than the automatically generated anchors we build in the toc
plugin. this can happen if, for example, you use the `multimarkdown`
plugin, which inserts `id` tags for every header it encounters. this
also leverages the `headinganchors` plugin nicely.

keeps backwards-compatibility with old toc-generated #indexXhY
anchors.
2017-05-16 08:55:23 +01:00
Simon McVittie c72dc5ddb7 mdwn: Don't enable alphabetically labelled ordered lists by default
This avoids misinterpreting initials ("C. S. Lewis was an author"),
the abbreviation for Monsieur ("M. Descartes was a philosopher") and
German page numbering ("S. 42") as ordered lists if they happen to
begin a line.

This only affects the default Discount implementation: Text::Markdown
and Text::MultiMarkdown do not have this feature anyway. A new
mdwn_alpha_list option can be used to restore the old interpretation.
2017-05-16 08:09:15 +01:00
Simon McVittie 4db4e589e4 mdwn: Enable footnotes by default when using Discount
A new mdwn_footnotes option can be used to disable footnotes in
MultiMarkdown and Discount.
2017-05-14 18:16:53 +01:00
Simon McVittie 81c3258269 mdwn: Don't mangle <style> into <elyts> under some circumstances
We can ask libdiscount not to elide <style> blocks, which means we
don't have to work around them.
2017-05-14 17:45:55 +01:00
Simon McVittie 5d65c1ad2c mdwn: Make flags passed to libdiscount explicit
The Perl binding defaults to MKD_NOHEADER|MKD_NOPANTS anyway, but
making them explicit means we can use other flags of our choice,
and makes it easier to justify why those flags are appropriate.
2017-05-14 17:34:12 +01:00
Simon McVittie 31c89db246 httpauth: If REMOTE_USER is empty, behave as though it was unset
A frequently cut-and-pasted HTTP basic authentication configuration
for nginx sets it to the empty string when not authenticated, which
is not useful.
2017-05-14 15:37:45 +01:00
Simon McVittie 2486d83706 remove: make it clearer that repeated page parameter is OK here
ikiwiki's web interface does not currently have UI for removing
multiple pages simultaneously, but the remove plugin is robust
against doing so. Use a clearer idiom to make that obvious.
2017-01-11 18:11:21 +00:00
Simon McVittie d157a97452 CGI, attachment, passwordauth: harden against repeated parameters
These instances of code similar to OVE-20170111-0001 are not believed
to be exploitable, because defined(), length(), setpassword(),
userinfo_set() and the binary "." operator all have prototypes that
force the relevant argument to be evaluated in scalar context. However,
using a safer idiom makes mistakes less likely.

(cherry picked from commit 69230a2220f673c66b5ab875bfc759b32a241c0d)
2017-01-11 18:11:07 +00:00
Simon McVittie b642cbef80 passwordauth: avoid userinfo forgery via repeated email parameter
OVE-20170111-0001

(cherry picked from commit bffb71d6a7d28f6dd5f0be241f214e79eea7bb91)
2017-01-11 18:11:07 +00:00
Simon McVittie f357856448 passwordauth: prevent authentication bypass via multiple name parameters
Calling CGI::FormBuilder::field with a name argument in list context
returns zero or more user-specified values of the named field, even
if that field was not declared as supporting multiple values.
Passing the result of field as a function parameter counts as list
context. This is the same bad behaviour that is now discouraged
for CGI::param.

In this case we pass the multiple values to CGI::Session::param.
That accessor has six possible calling conventions, of which four are
documented. If an attacker passes (2*n + 1) values for the 'name'
field, for example name=a&name=b&name=c, we end up in one of the
undocumented calling conventions for param:

    # equivalent to: (name => 'a', b => 'c')
    $session->param('name', 'a', 'b', 'c')

and the 'b' session parameter is unexpectedly set to an
attacker-specified value.

In particular, if an attacker "bob" specifies
name=bob&name=name&name=alice, then authentication is carried out
for "bob" but the CGI::Session ends up containing {name => 'alice'},
an authentication bypass vulnerability.

This vulnerability is tracked as OVE-20170111-0001.

(cherry picked from commit e909eb93f4530a175d622360a8433e833ecf0254)
2017-01-11 18:11:06 +00:00
Simon McVittie 0463357392 git: don't redundantly pass "--" to git_sha1
git_sha1 already puts "--" before its arguments, so

    git_sha1_file($dir, 'doc/index.mdwn')

would have incorrectly invoked

    git rev-list --max-count=1 HEAD -- -- doc/index.mdwn

If there is no file in the wiki named "--", that's harmless, because
it merely names the latest revision in which either "--" or
"doc/index.mdwn" changed. However, it could return incorrect results
if there is somehow a file named "--".
2017-01-09 13:58:58 +00:00
Simon McVittie 59632384d9 git: use parameters, not global state, to swap working directory 2017-01-09 13:50:54 +00:00
Simon McVittie c29c230c33 Revert "git: Turn $git_dir into a stack"
Now that we have avoided using in_git_dir recursively, we don't need
the stack any more.

This reverts commit 39b8931ad3.
2017-01-09 13:07:24 +00:00
Simon McVittie 6504456454 git: do not mix in_git_dir with eval{}
If we throw an exception (usually from run_or_die), in_git_dir won't
unshift the current directory from the stack. That's usually fine,
but in rcs_preprevert we catch exceptions and do some cleanup before
returning, for which we need the git directory to be the root and
not the temporary working tree.
2017-01-09 13:07:24 +00:00
Simon McVittie 9e7f0a6c59 Use rel=nofollow microformat for dynamic (CGI-related) URLs
Some of these might be relatively expensive to dereference or result
in messages being logged, and there's no reason why a search engine
should need to index them. (In particular, we'd probably prefer search
engines to index the rendered page, not its source code.)
2017-01-09 13:07:24 +00:00
Simon McVittie d092b0b777 git: Do not disable commit hook for temporary working tree
We exclude .git/hooks from symlinking into the temporary working tree,
which avoids the commit hook being run for the temporary branch anyway.
This avoids the wiki not being updated if an orthogonal change is
received in process A, while process B prepares a revert that is
subsequently cancelled.
2016-12-29 20:46:38 +00:00
Simon McVittie afda054796 git: Attribute reverts to the user doing the revert, not the wiki itself 2016-12-29 20:43:15 +00:00
Simon McVittie 4ad4fc33b5 git: write proposed attachment to temp file without going via system() 2016-12-28 21:32:12 +00:00
Simon McVittie 7f2235478d git: change calling convention of safe_git to have named arguments 2016-12-28 21:32:12 +00:00