Mercurial > prosody-modules
annotate mod_http_hostaliases/mod_http_hostaliases.lua @ 4700:f821eeac0e50
mod_pastebin: Fix pasting when <body> is not the first tag (thanks thorsten)
Introduced in ded630a87563
stanza:get_child() and :get_child_text() operates on the first child
when no name or namespace is given.
If it so happens that the first child is an <thread/> instead of <body>
then it calculates the line length against that instead of the body.
Apparently in the vast majority of clients the <body> is first, so this
issue was not noticed until now.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 29 Sep 2021 13:39:59 +0200 |
parents | 29e3a09275c5 |
children |
rev | line source |
---|---|
2265
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 module:set_global(); |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local host_map = { }; |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 module:wrap_object_event(require "net.http.server"._events, false, function (handlers, event_name, event_data) |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 local verb, host, path = event_name:match("^(%w+ )(.-)(/.*)"); |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 host = host_map[host]; |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 event_name = verb .. host .. path; |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 return handlers(event_name, event_data); |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 end); |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 function module.add_host(module) |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 local http_host = module:get_option_string("http_host"); |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 for host in module:get_option_set("http_host_aliases", {}) do |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 host_map[host] = http_host; |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 end |
29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 end |