MCPcopy Create free account
hub / github.com/apache/httpd / splitout_queryargs

Function splitout_queryargs

modules/mappers/mod_rewrite.c:837–896  ·  view source on GitHub ↗

* split out a QUERY_STRING part from * the current URI string */

Source from the content-addressed store, hash-verified

835 * the current URI string
836 */
837static void splitout_queryargs(request_rec *r, int flags)
838{
839 char *q;
840 int split, skip;
841 int qsappend = flags & RULEFLAG_QSAPPEND;
842 int qsdiscard = flags & RULEFLAG_QSDISCARD;
843 int qslast = flags & RULEFLAG_QSLAST;
844
845 if (flags & RULEFLAG_QSNONE) {
846 rewritelog(r, 2, NULL, "discarding query string, no parse from substitution");
847 r->args = NULL;
848 return;
849 }
850
851 /* don't touch, unless it's a scheme for which a query string makes sense.
852 * See RFC 1738 and RFC 2368.
853 */
854 if ((skip = is_absolute_uri(r->filename, &split))
855 && !split) {
856 r->args = NULL; /* forget the query that's still flying around */
857 return;
858 }
859
860 if (qsdiscard) {
861 r->args = NULL; /* Discard query string */
862 rewritelog(r, 2, NULL, "discarding query string");
863 }
864
865 q = qslast ? ap_strrchr(r->filename + skip, '?') : ap_strchr(r->filename + skip, '?');
866
867 if (q != NULL) {
868 char *olduri;
869 apr_size_t len;
870
871 olduri = apr_pstrdup(r->pool, r->filename);
872 *q++ = '\0';
873 if (qsappend) {
874 if (*q) {
875 r->args = apr_pstrcat(r->pool, q, "&" , r->args, NULL);
876 }
877 }
878 else {
879 r->args = apr_pstrdup(r->pool, q);
880 }
881
882 if (r->args) {
883 len = strlen(r->args);
884
885 if (!len) {
886 r->args = NULL;
887 }
888 else if (r->args[len-1] == '&') {
889 r->args[len-1] = '\0';
890 }
891 }
892
893 rewritelog(r, 3, NULL, "split uri=%s -> uri=%s, args=%s", olduri,
894 r->filename, r->args ? r->args : "<none>");

Callers 1

apply_rewrite_ruleFunction · 0.85

Calls 3

is_absolute_uriFunction · 0.85
ap_strrchrFunction · 0.85
ap_strchrFunction · 0.85

Tested by

no test coverage detected