Commit Graph

197 Commits

Author SHA1 Message Date
a6ca71b131 check a length when validating an email
An email address has two parts:
 - the local part (before the "@") = max 64 characters
 - the domain part (after the "@") = max 255 characters
So maximum length is 64 + @ + 255 = 320 characters

https://www.rfc-editor.org/rfc/rfc5321.html#section-4.5.3.1
2024-09-08 02:05:43 +02:00
68e7f44a76 do not send content when there is a htmx redirect 2024-07-11 21:58:52 +02:00
b2f4c065ea remove a code to finish job requests when winix exits
Actually there was a bug and the code was not correctly waiting for the job requests.
2024-07-02 17:30:35 +02:00
c30b7db041 add closing dialogs, redirecting and removing content functionality to the winix framework
add such new methods to FunctionBase:
- bool can_push_url_to_browser_history();
- void add_standard_models();
- void close_modal_dialogs();

- void prepare_doc_url(const wchar_t * local_url, pt::WTextStream & url);
- void prepare_doc_url(const wchar_t * local_url, std::wstring & url);
- std::wstring prepare_doc_url(const wchar_t * local_url = nullptr);
- std::wstring prepare_doc_url(const std::wstring & local_url);

- void redirect_to(const wchar_t * url, bool append_domain = true);
- void redirect_to(const std::wstring & url, bool append_domain = true);
- void redirect_to(const pt::WTextStream & url, bool append_domain = true);

- void redirect_to(const wchar_t * url, const wchar_t * frame_url, const wchar_t * dom_target);
- void redirect_to(const std::wstring & url, const std::wstring & frame_url, const std::wstring & dom_target);
- void redirect_to(pt::WTextStream & url, pt::WTextStream & frame_url, pt::WTextStream & dom_target);
- void redirect_to(pt::WTextStream & url, pt::WTextStream & frame_url, const wchar_t * dom_target);
- void redirect_to(const wchar_t * url, const wchar_t * frame_url, pt::WTextStream & dom_target);

- void retarged(const wchar_t * frame, const wchar_t * dom_target, const wchar_t * push_url = nullptr, const wchar_t * swap_algorithm = nullptr);
- void retarged(const std::wstring & frame, const std::wstring & dom_target, const std::wstring & push_url, const wchar_t * swap_algorithm = nullptr);
- void retarged(const wchar_t * frame, pt::WTextStream & dom_target, const wchar_t * push_url = nullptr, const wchar_t * swap_algorithm = nullptr);

- void remove_content(pt::WTextStream & dom_target, bool close_dialogs = false);
- void remove_content(const wchar_t * dom_target, bool has_postfix, long dom_target_postfix, bool close_dialogs = false);
- void remove_content(const wchar_t * dom_target, long dom_target_postfix, bool close_dialogs = false);
- void remove_content(const wchar_t * dom_target, bool close_dialogs = false);

- void update_content(const wchar_t * frame, pt::WTextStream & dom_target, bool close_dialogs = false);
- void update_content(const wchar_t * frame, const wchar_t * dom_target, bool has_postfix, long dom_target_postfix, bool close_dialogs = false);
- void update_content(const wchar_t * frame, const wchar_t * dom_target, long dom_target_postfix, bool close_dialogs = false);
- void update_content(const wchar_t * frame, const wchar_t * dom_target, bool close_dialogs = false);

while here:
- refactor PascalCase to snake_case in FunctionBase
- add start_request() and finish_request() methods to FunctionBase
- add has_*_access() methods to FunctionBase
- fix: FunctionBase::clear() method was not called if a request was assigned to a job
- add a WinixEzcHelper model
- allow to serialize a header if the header value is neither a string nor an integer
- refactor PascalCase to snake_case in functions: Emacs, Mkdir, Upload
2024-06-27 10:57:08 +02:00
6aa100f12c WIP: remove the old database abstraction layer
remove such classes:
- DbBase
- DbConn
- DbTextStream
- Db

while here:
- remove: TextStream, SLog, TexTextStream
2024-06-22 18:03:54 +02:00
5d457f3d4b (update to the new pikotools api): use a char32_t character as a main character when converting strings
Use a char32_t instead of a wchar_t type. This is needed on systems
where sizeof(wchar_t) is equal to 2.

This affects classes based on the pt::Stream such as Log and HtmlTextStream.
2024-06-01 00:33:15 +02:00
1c850b12ec add a q_encode(...) method to misc 2024-04-28 16:14:57 +02:00
dbf7dfab82 improve the startup help messages 2024-03-08 22:01:33 +01:00
b753464608 add some operators to the Log class
add:
virtual Log & operator<<(long double);
virtual Log & operator<<(float);
virtual Log & operator<<(long long unsigned int);
virtual Log & operator<<(unsigned int);
virtual Log & operator<<(short unsigned int);
virtual Log & operator<<(long long int);
virtual Log & operator<<(short int);
virtual Log & operator<<(bool);
virtual Log & operator<<(unsigned char);
virtual Log & operator<<(const pt::Stream &);
2024-02-13 22:29:22 +01:00
f4470ccbe7 allow to not set the res value from a plugin function
Add PluginInfo::has_res (bool, default true). If set to false by a plugin function
then the PluginInfo::res value is not taken into account when calculating how many plugins
have returned true or false.
2024-01-04 15:57:29 +01:00
71ad4869ce fix: take into account hours when calculating a relative timezone dst 2023-12-27 16:25:54 +01:00
09dc6782c8 fix: remember the first/last weekday flags from a timezone DST
If a date is given in a relative form with first/last parameters,
we must remember them in order to select the appropriate day
of the week from the appropriate year.
2023-12-24 14:55:39 +01:00
0cebb2dc52 allow to use a first|last weekday name when defining a timezone dst
the format of a 'start' or 'end' field in a dst is:
MM-[first|last]:[monday|tuesday|wednesday|thursday|friday|saturday|sunday] HH:MM:SS
or just as beforehand: MM-DD HH:MM:SS

a sample timezone:
{
name = "tz_+01:00d"
id = "40"
offset_str = "+01:00"

dst = (

{
year = "2001"
has_dst = true
offset_str = "+01:00"
start  	   = "03-last-sunday 01:00"
end    	   = "10-last-sunday 01:00"
}

) # end of dst
}
2023-12-20 03:58:21 +01:00
a54d70bed4 add a 422 Header status - Unprocessable Entity 2023-11-08 17:59:40 +01:00
79babc916a add a Request::raw_post buffer
This buffer is used when a Function::NeedToCopyRawPost() method returned true.

while here:
- remove WINIX_POST_PARAMS and WINIX_RAW_POST_STRING plugin messages
2023-11-02 05:14:48 +01:00
e600aebaae add a RequestJobBase base class for requests jobs 2023-09-28 07:47:06 +02:00
79e971cb76 parse the input body for the PUT and PATCH methods too 2023-09-15 10:04:25 +02:00
f7e077a7c5 add a TimeZone::PrintOffset(...) method 2023-08-29 15:02:37 +02:00
6d256e6512 fix: correctly set a Request::RunState::job_run flag to the background request
The flag should be set to the task.request and not to the cur->request.
The cur->request could have been already changed by the main thread.
2023-08-25 16:24:27 +02:00
52f9d399ca add a Header::text_xml and text_xml_utf8 types 2023-07-31 17:31:22 +02:00
bf79e46411 add a GetUTF8File(...) method with a pt::WTextStream & content to the misc 2023-07-04 22:59:57 +02:00
1655ae3562 fix: correctly clear after a request when an exception has been thrown 2023-05-16 15:31:13 +02:00
2e455f97ac add support for serializing to xml 2023-02-27 00:34:29 +01:00
99fbf6ca27 add WINIX_STARTED plugin message 2022-10-19 14:26:34 +02:00
f050fc2316 make more virtual functions is BaseThread 2022-10-19 14:26:18 +02:00
77a00f5989 fix: return a correct status from Dirs::AddDirectory() 2022-10-17 08:13:20 +02:00
8edd0ef07a fix: use the base_url as a domain when creating a session cookie if a cookie domain is empty 2022-09-28 19:28:17 +02:00
6138497fe0 change how origin header is treated
Now check whether the origin is in allowed_origins table,
and if not check allow_all_origins config parameter.

While here:
- add are_cors_preflight_requests_available - if true then preflight
  requests are available (default false)
2022-09-09 01:01:39 +02:00
05ecac8426 add support for more cookie flags in Request::AddCookie() method
changed in config options:
- renamed: http_session_id_name to session_cookie_name
- add config options: session_cookie_path, session_cookie_domain, session_cookie_same_site,
  session_cookie_http_only, session_cookie_secure
2022-09-08 05:40:44 +02:00
222a1c8a1f refactor the algorithm for testing the cors
while here:
- send cors headers even if the status is 404
- add: access_control_expose_headers config option - list of additional headers sent in Access-Control-Expose-Headers
- add: access_control_allow_credentials config option - if true return Access-Control-Allow-Credentials header equal "true"
2022-09-08 03:12:44 +02:00
04164ff967 add Access-Control-Allow-Credentials for simple requests too 2022-09-07 15:25:48 +02:00
9f64692ede set Access-Control-Allow-Credentials if available 2022-09-07 14:46:29 +02:00
bff435db9a add WINIX_SAVE_FILELOG plugin message 2022-09-01 07:34:10 +02:00
e378fcfe3b remove not used variables from Request 2022-08-31 21:33:54 +02:00
a7a338f28e fix(Request): allow to prepare integer headers 2022-08-31 21:25:14 +02:00
a19158cb62 add config options for testing the Origin header in cors requests
- allow_all_cors_origins - whether or not to allow all origins
- allowed_cors_origins - a list of allowed origins (used if allow_all_cors_origins is false)
2022-08-31 20:42:42 +02:00
217f42b7c6 add support for preflight requ (cors) 2022-08-30 01:52:02 +02:00
a34db6505d move some methods from App to Request
methods moved: SetEnv(), ReadEnvVariables(), ReadEnvRemoteIP(), CheckSSL(), SetSubdomain()

while here:
- add the rest of http methods: put, connect, trace, patch
2022-08-29 19:20:41 +02:00
d3a440fa0a add Request::AddPostVar(pt::Space & space, const wchar_t * name) 2022-08-22 16:03:07 +02:00
5dd34c802e add Request::job_second_id 2022-08-20 00:31:10 +02:00
ceb5336ca1 add support for OPTIONS http method 2022-08-11 08:04:40 +02:00
6266eac729 use std::wstring_view in SessionIdManager::DecodeToken(...) method 2022-08-10 12:42:16 +02:00
968660e8ca fix: set correctly request->session
The session cookie was not created because request->session pointed at
a temporary session.

While here:
- do some cleaning in App
- set request->mount too
- add fcgi_cannot_create_request_delay to the config
- fix: in mailregister plugin get model_connector from env (and not from the request)
2022-07-30 18:37:50 +02:00
9d8d35b64f save logs after a job has finished 2022-07-30 03:35:00 +02:00
9e6a5b2d37 add use_internal_session_mechanism and use_internal_loggin_mechanism config options 2022-07-26 21:54:33 +02:00
c85a724fec fix(SessionIdManager): take a correct algorithm when decoding a token 2022-07-26 21:09:44 +02:00
2e8f4d1a26 allow the SessionIdManager to use only two keys 2022-07-26 05:18:42 +02:00
522b57ade4 fix(Jobs): change request state to prepare_to_finish in case of an error 2022-07-25 18:37:39 +02:00
d4da6aa518 let System::PutUrlProto takes a stream by a reference to pt::Stream 2022-07-25 18:36:28 +02:00
979ef907fe allow a request to be processed in a job
Now we allow a request to be passed into a job queue,
and after the job finishes the request is passed into
a controller again. In order to achieve this we have
a requests queue in System, when we put a request
to the job this Request structure is preserved in the
queue and for a new request a new Request is added to
the queue.

while here:
- remove App::Lock()/Unlock(), use scoped locking
- fix: Plugin now has a Call method which takes ModelConnector
  and a logger (used in multithreaded environment)
- BaseThread has a main_model_connector pointer
  to the main (from the main thread) model connector
- the FastCGI structure fcgi_request moved from App to Request
- some methods for handling requests moved from App to Request
- small refactoring in main.cpp
- add Http class (a http client)
2022-07-25 14:21:21 +02:00