Bug 61166 - RewriteMap: URLs with whitespace (txt, dbm)
Summary: RewriteMap: URLs with whitespace (txt, dbm)
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_rewrite (show other bugs)
Version: 2.5-HEAD
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-07 20:19 UTC by Jeffrey T. Frey
Modified: 2022-10-11 22:31 UTC (History)
2 users (show)



Attachments
bzipped, tar containing two git diff patches (3.66 KB, application/x-bzip2)
2017-06-07 20:19 UTC, Jeffrey T. Frey
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey T. Frey 2017-06-07 20:19:38 UTC
Created attachment 35037 [details]
bzipped, tar containing two git diff patches

1. The 'dbd' and 'prg' RewriteMap types can match a candidate pattern that includes whitespace characters.
2. The 'dbm' RewriteMap type is also capable of doing this, except for the fact that the included 'httxt2dbm' support utility will not properly parse a txt file containing whitespace inside a URL.
3. The 'txt' RewriteMap type will not properly parse URLs containing whitespace.

This problem has come up repeatedly on message boards and we have encountered it, as well.  There are numerous hacks (e.g. re-encode the URL before passing to the map and use percent-encoded form in the 'txt' map).  However, supporting very simple quoting is easy enough.

Attached are "git diff" files for:

"modules/mappers/mod_rewrite.c": allow for single- and double-quote delimited strings in the text mapping file, with backslash-escaping of the chosen quote permissible

"support/httxt2dbm.c": allow for single- and double-quote delimited strings in the text mapping file, with backslash-escaping of the chosen quote permissible; also includes an option to enable application of an unescape function to the parsed keys and values before adding them to the DBM file


The patches are against the HEAD of the current git repo; the modifications have been extensively tested on current Apache 2.4 and 2.2 releases.
Comment 1 Jason Pyeron 2021-12-05 06:21:55 UTC
work around:

echo -e 'key line\nvalue line' | db_load -T -t hash mapfile.db
Comment 2 Raphaël Droz 2022-10-11 22:31:27 UTC
Still annoying.

I don't know of any suitable workaround for {space} inside a txt RewriteMap. There is no "%-encoding" workaround and no way to actually filter the MatchingKey (unlike the MatchingValue)