Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
Loading...
Searching...
No Matches
native_dynamic_request_fields.c File Reference

URL decoding, query-string parsing, and form-value extraction for in-process dynamic request handling. More...

#include "native_dynamic_request_fields.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

static int hex_digit_value (char c)
char * native_dynamic_url_decode (const char *encoded)
 Decodes a percent-encoded URL string.
static char * extract_value_for_key (const char *source, const char *key, char separator)
char * native_dynamic_query_value (const char *query, const char *key)
 Extracts a parameter value from a query string.
char * native_dynamic_form_value (const char *body, const char *key)
 Extracts a value from a URL-encoded form body.
char * native_dynamic_cookie_value (const char *cookie_header, const char *name)
 Extracts a cookie value from a Cookie header string.

Detailed Description

URL decoding, query-string parsing, and form-value extraction for in-process dynamic request handling.

Definition in file native_dynamic_request_fields.c.

Function Documentation

◆ extract_value_for_key()

char * extract_value_for_key ( const char * source,
const char * key,
char separator )
static

◆ hex_digit_value()

int hex_digit_value ( char c)
static

Definition at line 17 of file native_dynamic_request_fields.c.

Referenced by native_dynamic_url_decode().

◆ native_dynamic_cookie_value()

char * native_dynamic_cookie_value ( const char * cookie_header,
const char * name )

Extracts a cookie value from a Cookie header string.

Searches cookie_header for name=value pairs separated by ; and returns the decoded value for the first match.

Parameters
cookie_headerRaw Cookie header value.
nameCookie name to look up.
Returns
Newly allocated cookie value, or NULL if not found. Caller must free.

Definition at line 148 of file native_dynamic_request_fields.c.

References extract_value_for_key().

Referenced by active_user_id_from_cookie_runtime(), csrf_token_from_cookie(), handle_request_cookie_value_command(), request_has_session_cookie(), and revoke_session_by_cookie_runtime().

◆ native_dynamic_form_value()

char * native_dynamic_form_value ( const char * body,
const char * key )

Extracts a value from a URL-encoded form body.

Searches body for key=value pairs separated by & and returns the decoded value for the first match.

Parameters
bodyURL-encoded form body.
keyForm field name to look up.
Returns
Newly allocated decoded value, or NULL if not found. Caller must free.

Definition at line 144 of file native_dynamic_request_fields.c.

References extract_value_for_key().

Referenced by csrf_request_token_dup_runtime(), handle_action_route(), handle_request_form_value_command(), and request_form_value_dup_runtime().

◆ native_dynamic_query_value()

char * native_dynamic_query_value ( const char * query,
const char * key )

Extracts a parameter value from a query string.

Searches query for key=value pairs separated by & and returns the decoded value for the first match.

Parameters
queryRaw query string (without the leading ? ).
keyParameter name to look up.
Returns
Newly allocated decoded value, or NULL if not found. Caller must free.

Definition at line 140 of file native_dynamic_request_fields.c.

References extract_value_for_key().

Referenced by handle_request_query_value_command(), login_page_params_json_dup_runtime(), register_page_params_json_dup_runtime(), and resolve_declared_page_params_json_runtime().

◆ native_dynamic_url_decode()

char * native_dynamic_url_decode ( const char * encoded)

Decodes a percent-encoded URL string.

Allocates a new buffer containing the decoded result. The + character is decoded as a space.

Parameters
encodedPercent-encoded input string.
Returns
Newly allocated decoded string, or NULL on allocation failure. Caller must free.

Definition at line 24 of file native_dynamic_request_fields.c.

References hex_digit_value(), and len.

Referenced by extract_value_for_key().