features included: 1. Support for SubstituteCond - ability to apply substitute rule only if the configured conditions are met. The conditions input could be compared to request data, environment variables and internal Apache notes. -- This section is similiar to RewriteCond, and I think it should go to a common section in the code. 2. Support for SubstituteCheck – ability to perform quick search on the data and use the results in order to avoid using “expensive” regular expression. 3. Supporting evaluation (at run time) of the searched and replaced patterns before application (instead of static evaluation in configuration time). Evaluation result could be taken from request/response headers, environment variables and internal Apache notes. 4. Adding some more options: a. Skip the replaced text from being processed by following rules. -- For this, I used a binary tree, which I didn't find in APR, can you consider adding such implementation to APR? b. Stop applying other rules after specific rule is matched. c. Option not to break the response into lines (and apply the substitute rules on the whole response). I know these changes need documentation, which I can provide, just I want to know if they will accepted into the trunk, before writing it. I hope you will find these changes helpful, and I'll be glad to hear your opinion about them.
Created attachment 27051 [details] Patch + new .h file as gzipped tarball
*** Bug 47220 has been marked as a duplicate of this bug. ***
Thank you for your interest, and contribution. Note that it is very unlikely to be adopted at this time, as httpd 2.3-beta (soon to be 2.4) deprecated mod_substitute, and introduced mod_sed. I'd strongly encourage you to review mod_sed and determine if any of the improvements you propose to mod_substitute remain applicable to mod_sed, and absolutely offer them as a patch to httpd 2.3. All this said, httpd is a collaborative environment, and I will leave your ticket open for others to evaluate. It's entirely possible you would find enough httpd committers to entertain the idea of restoring an enhanced mod_substitute, if mod_sed is not so easily tailored.
Hi I think that mod_substitute with my new features is doing very good job (depends on Admin configuration). I don't see any reason why to dreprecate the existing mod_substitute (taking into account that new module usually brings new bugs). Since mod_sed is not exist in "released" version, it is hard for me to use it in my environement (and I'm quite sure there are many developers with this problem). Why not give the user option to choose which module she wants to use? Regards, Yehezkel
I've tried the patch specifically to substitute in environment variables (%{env:var_name}) but it seems to only allow access to local variables created by the use of 'define' (${var_name}). Please could you confirm how your code is to be used in this manner?
Thanks Yehezkel, For anyone else who has this problem - it can be fixed by appending 'e' to the substitution command.
How to use the patch file? Can't seem to use it with patch tool for Windows. Thanks!
(In reply to ambqqpdp from comment #7) > How to use the patch file? Can't seem to use it with patch tool for Windows. > > Thanks! It was created with Unix diff command. Use Unix patch command to apply it.
Hmm, it seems that the attachement is a tar.gz at first. The patch itself may be contained.
(In reply to Yann Ylavic from comment #9) > Hmm, it seems that the attachement is a tar.gz at first. > The patch itself may be contained. I tried saving it as tar.gz but uncompressing it returns an error. I will try horowity's suggestion. Thanks!
(In reply to horowity@checkpoint.com from comment #8) > (In reply to ambqqpdp from comment #7) > > How to use the patch file? Can't seem to use it with patch tool for Windows. > > > > Thanks! > > It was created with Unix diff command. > Use Unix patch command to apply it. patch unexpectedly ends in middle of line patch: **** Only garbage was found in the patch input.
Comment on attachment 27051 [details] Patch + new .h file as gzipped tarball The attachment is in tar.gz format. I have changed the meta data so that browsers won't try to display the raw binary file.
(In reply to Rainer Jung from comment #12) > Comment on attachment 27051 [details] > Patch + new .h file as gzipped tarball > > The attachment is in tar.gz format. I have changed the meta data so that > browsers won't try to display the raw binary file. Thank you very much
I'm having problems upon compiling the patched source when targeting Apache 2.2, but for 2.4 it's perfectly working. The error seems to be coming from some functions not defined in 2.2 such as ap_regexec_len, etc.
(In reply to ambqqpdp from comment #14) > I'm having problems upon compiling the patched source when targeting Apache > 2.2, but for 2.4 it's perfectly working. The error seems to be coming from > some functions not defined in 2.2 such as ap_regexec_len, etc. The ap_regexec_len was submitted in #51231, and is very easy to adopt. So if you need these features in 2.2.x - you can just apply both of patches.
Created attachment 33182 [details] Update of original patch. In how, the original patch is not applying to 2.2.x any more due to a code change, so I attach an update patch.
Hi several years were passed since my original commit and I got several private mails with questions about the patch, so you might want to reconsider adopting the patch to 2.4/trunk (even if mod_sed is considered as replacement of mod_substitute). Anyhow, the original patch is not applying to 2.2.x any more due to a code change, so I attach an update patch (#33182). Regards, Yehezkel Horowitz