diff --git a/swad_API.c b/swad_API.c index 590a79d6..e0bbb50e 100644 --- a/swad_API.c +++ b/swad_API.c @@ -1429,7 +1429,7 @@ static int API_WritePlainTextIntoHTMLBuffer (struct soap *soap, /***** Write plain text into text buffer *****/ /* Convert to respectful HTML and insert links */ Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - TxtHTML,Cns_MAX_BYTES_LONG_TEXT,false); // Convert from HTML to recpectful HTML + TxtHTML,Cns_MAX_BYTES_LONG_TEXT,Str_DONT_REMOVE_SPACES); ALn_InsertLinks (TxtHTML,Cns_MAX_BYTES_LONG_TEXT,60); // Insert links /* Write text */ diff --git a/swad_agenda.c b/swad_agenda.c index d0cf1a2f..a84aa0cc 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -847,7 +847,7 @@ static void Agd_ShowOneEvent (struct Agd_Agenda *Agenda, The_GetSuffix ()); Agd_DB_GetEventTxt (&AgdEvent,Txt); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML + Txt,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links HTM_Txt (Txt); HTM_DIV_End (); diff --git a/swad_announcement.c b/swad_announcement.c index 044ed2bd..62cfb227 100644 --- a/swad_announcement.c +++ b/swad_announcement.c @@ -391,7 +391,7 @@ void Ann_ReceiveAnnouncement (void) /* Get the content of the announcement */ Par_GetParAndChangeFormat ("Content",Content,Cns_MAX_BYTES_TEXT, - Str_TO_RIGOROUS_HTML,true); + Str_TO_RIGOROUS_HTML,Str_REMOVE_SPACES); /* Get users who can view this announcement */ Roles = Rol_GetSelectedRoles (); diff --git a/swad_assignment.c b/swad_assignment.c index df7d5ae8..9d0a2158 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -571,7 +571,7 @@ static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments, /* Text of the assignment */ Asg_DB_GetAssignmentTxtByCod (Assignments->Asg.AsgCod,Txt); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML + Txt,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links if (PrintView) HTM_TD_Begin ("colspan=\"2\" class=\"LT\""); diff --git a/swad_attendance.c b/swad_attendance.c index 2ac93eff..603730ab 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -519,7 +519,7 @@ static void Att_ShowOneEventRow (struct Att_Events *Events, /* Text of the attendance event */ Att_DB_GetEventDescription (Events->Event.AttCod,Description); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Description,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML + Description,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); ALn_InsertLinks (Description,Cns_MAX_BYTES_TEXT,60); // Insert links if (ShowOnlyThisAttEventComplete) HTM_TD_Begin ("colspan=\"2\" class=\"LT\""); @@ -1790,7 +1790,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr, else // Show without form { Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - CommentStd,Cns_MAX_BYTES_TEXT,false); + CommentStd,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); HTM_Txt (CommentStd); } HTM_TD_End (); @@ -1813,7 +1813,8 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr, else if (Event->CommentTchVisible) // Show without form { Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - CommentTch,Cns_MAX_BYTES_TEXT,false); + CommentTch,Cns_MAX_BYTES_TEXT, + Str_DONT_REMOVE_SPACES); HTM_Txt (CommentTch); } HTM_TD_End (); @@ -3209,7 +3210,8 @@ static void Att_ListAttEventsForAStd (struct Att_Events *Events, if (ShowCommentStd) { Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - CommentStd,Cns_MAX_BYTES_TEXT,false); + CommentStd,Cns_MAX_BYTES_TEXT, + Str_DONT_REMOVE_SPACES); HTM_DT_Begin (); HTM_TxtColon (Txt_Student_comment); HTM_DT_End (); @@ -3220,7 +3222,8 @@ static void Att_ListAttEventsForAStd (struct Att_Events *Events, if (ShowCommentTch) { Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - CommentTch,Cns_MAX_BYTES_TEXT,false); + CommentTch,Cns_MAX_BYTES_TEXT, + Str_DONT_REMOVE_SPACES); HTM_DT_Begin (); HTM_TxtColon (Txt_Teachers_comment); HTM_DT_End (); diff --git a/swad_browser.c b/swad_browser.c index b8f85c41..4b114497 100644 --- a/swad_browser.c +++ b/swad_browser.c @@ -2147,7 +2147,8 @@ static void Brw_GetParsPathInTreeAndFileName (void) // File names with heading and trailing spaces are allowed if (Par_GetParAndChangeFormat (Brw_FileTypeParName[FileType], Gbl.FileBrowser.FilFolLnk.Name, - NAME_MAX,Str_TO_TEXT,false)) + NAME_MAX,Str_TO_TEXT, + Str_DONT_REMOVE_SPACES)) { Gbl.FileBrowser.FilFolLnk.Type = FileType; diff --git a/swad_call_for_exam.c b/swad_call_for_exam.c index 681b98a8..bb8b7aae 100644 --- a/swad_call_for_exam.c +++ b/swad_call_for_exam.c @@ -1248,7 +1248,7 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams, { Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, CallsForExams->CallForExam.Place, - Cns_MAX_BYTES_TEXT,false); + Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); HTM_Txt (CallsForExams->CallForExam.Place); } HTM_TD_End (); @@ -1279,7 +1279,7 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams, { Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, CallsForExams->CallForExam.Mode, - Cns_MAX_BYTES_TEXT,false); + Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); HTM_Txt (CallsForExams->CallForExam.Mode); } HTM_TD_End (); @@ -1311,7 +1311,7 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams, { Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, CallsForExams->CallForExam.Structure, - Cns_MAX_BYTES_TEXT,false); + Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); HTM_Txt (CallsForExams->CallForExam.Structure); } HTM_TD_End (); @@ -1343,7 +1343,7 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams, { Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, CallsForExams->CallForExam.DocRequired, - Cns_MAX_BYTES_TEXT,false); + Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); HTM_Txt (CallsForExams->CallForExam.DocRequired); } HTM_TD_End (); @@ -1375,7 +1375,7 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams, { Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, CallsForExams->CallForExam.MatRequired, - Cns_MAX_BYTES_TEXT,false); + Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); HTM_Txt (CallsForExams->CallForExam.MatRequired); } HTM_TD_End (); @@ -1407,7 +1407,7 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams, { Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, CallsForExams->CallForExam.MatAllowed, - Cns_MAX_BYTES_TEXT,false); + Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); HTM_Txt (CallsForExams->CallForExam.MatAllowed); } HTM_TD_End (); @@ -1439,7 +1439,7 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams, { Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, CallsForExams->CallForExam.OtherInfo, - Cns_MAX_BYTES_TEXT,false); + Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); HTM_Txt (CallsForExams->CallForExam.OtherInfo); } HTM_TD_End (); diff --git a/swad_changelog.h b/swad_changelog.h index 36297a90..179a3248 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -629,11 +629,12 @@ TODO: Emilce Barrera Mesa: Podr TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen. */ -#define Log_PLATFORM_VERSION "SWAD 22.118.10 (2023-05-30)" +#define Log_PLATFORM_VERSION "SWAD 22.118.11 (2023-05-30)" #define CSS_FILE "swad22.118.5.css" #define JS_FILE "swad22.49.js" /* - Version 22.118.10:May 30, 2023 Draw logo in head even if it does not exist. (337363 lines) + Version 22.118.11:May 30, 2023 Code refactoring in strings. (337391 lines) + Version 22.118.10:May 30, 2023 Draw logo in head even if it does not exist. (337359 lines) Version 22.118.9: May 30, 2023 Code refactoring in user account. (337363 lines) Version 22.118.8: May 30, 2023 Fixed bugs in users. (337361 lines) Version 22.118.7: May 30, 2023 Fixed bug in photo processing. Reported by Emilio Alemán Carmona. (337364 lines) diff --git a/swad_exam.c b/swad_exam.c index 66bd22fa..c52b2d1c 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -584,7 +584,7 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams,bool ShowOnlyThisExam) The_GetColorRows ()); Exa_DB_GetExamTxt (Exams->Exam.ExaCod,Txt); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML + Txt,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links HTM_DIV_Begin ("class=\"PAR %s_%s\"", Exams->Exam.Hidden ? "DAT_LIGHT" : diff --git a/swad_exam_log.c b/swad_exam_log.c index 1f189fc6..8cc7ce33 100644 --- a/swad_exam_log.c +++ b/swad_exam_log.c @@ -196,7 +196,7 @@ static void ExaLog_LogUsrAgent (long LogCod,long PrnCod) { Str_Copy (UserAgentDB,UserAgent,MaxBytes); Str_ChangeFormat (Str_FROM_TEXT,Str_TO_TEXT, - UserAgentDB,MaxBytes,true); + UserAgentDB,MaxBytes,Str_REMOVE_SPACES); } else UserAgentDB[0] = '\0'; diff --git a/swad_exam_print.c b/swad_exam_print.c index 6928207d..b10a20f1 100644 --- a/swad_exam_print.c +++ b/swad_exam_print.c @@ -617,8 +617,8 @@ static void ExaPrn_GetAndWriteDescription (long ExaCod) /***** Get description from database *****/ Exa_DB_GetExamTxt (ExaCod,Txt); - Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, // Convert from HTML to rigorous HTML - Txt,Cns_MAX_BYTES_TEXT,false); + Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, + Txt,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links /***** Write description *****/ diff --git a/swad_forum.c b/swad_forum.c index 5829b95f..3cfdb75d 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -2848,7 +2848,7 @@ void For_ReceiveForumPost (void) /***** Get message body *****/ Par_GetParAndChangeFormat ("Content",Content,Cns_MAX_BYTES_LONG_TEXT, - Str_TO_RIGOROUS_HTML,false); + Str_TO_RIGOROUS_HTML,Str_DONT_REMOVE_SPACES); /***** Initialize media *****/ Med_MediaConstructor (&Media); diff --git a/swad_game.c b/swad_game.c index fec59781..a0a7b9c8 100644 --- a/swad_game.c +++ b/swad_game.c @@ -628,7 +628,7 @@ static void Gam_ShowGameMainData (struct Gam_Games *Games, The_GetColorRows ()); Gam_DB_GetGameTxt (Games->Game.GamCod,Txt); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML + Txt,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links HTM_DIV_Begin ("class=\"PAR %s_%s\"", Games->Game.Hidden ? "DAT_LIGHT" : diff --git a/swad_info.c b/swad_info.c index 4aef4494..dc153abb 100644 --- a/swad_info.c +++ b/swad_info.c @@ -1443,7 +1443,8 @@ static bool Inf_CheckAndShowPlainTxt (void) /***** Convert to respectful HTML and insert links *****/ Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - TxtHTML,Cns_MAX_BYTES_LONG_TEXT,false); // Convert from HTML to recpectful HTML + TxtHTML,Cns_MAX_BYTES_LONG_TEXT, + Str_DONT_REMOVE_SPACES); ALn_InsertLinks (TxtHTML,Cns_MAX_BYTES_LONG_TEXT,60); // Insert links /***** Write text *****/ @@ -1769,9 +1770,9 @@ void Inf_RecAndChangePlainTxtInfo (void) Cns_MAX_BYTES_LONG_TEXT,NULL); Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,sizeof (Txt_MarkdownFormat) - 1); Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML, - Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous) + Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,Str_REMOVE_SPACES); Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN, - Txt_MarkdownFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store a copy in Markdown format + Txt_MarkdownFormat,Cns_MAX_BYTES_LONG_TEXT,Str_REMOVE_SPACES); // Store a copy in Markdown format /***** Update text of course info in database *****/ Inf_DB_SetInfoTxt (Txt_HTMLFormat,Txt_MarkdownFormat); @@ -1808,9 +1809,9 @@ void Inf_RecAndChangeRichTxtInfo (void) Cns_MAX_BYTES_LONG_TEXT,NULL); Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,sizeof (Txt_MarkdownFormat) - 1); Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML, - Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous) + Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,Str_REMOVE_SPACES); Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN, - Txt_MarkdownFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store a copy in Markdown format + Txt_MarkdownFormat,Cns_MAX_BYTES_LONG_TEXT,Str_REMOVE_SPACES); // Store a copy in Markdown format /***** Update text of course info in database *****/ Inf_DB_SetInfoTxt (Txt_HTMLFormat,Txt_MarkdownFormat); diff --git a/swad_log.c b/swad_log.c index 7aa876be..5def5b20 100644 --- a/swad_log.c +++ b/swad_log.c @@ -112,7 +112,7 @@ void Log_LogAccess (const char *Comments) { Str_Copy (CommentsDB,Comments,MaxLength); Str_ChangeFormat (Str_FROM_TEXT,Str_TO_TEXT, - CommentsDB,MaxLength,true); // Avoid SQL injection + CommentsDB,MaxLength,Str_REMOVE_SPACES); // Avoid SQL injection Log_DB_LogComments (LogCod,CommentsDB); free (CommentsDB); } diff --git a/swad_message.c b/swad_message.c index c2a6003e..a9a115ce 100644 --- a/swad_message.c +++ b/swad_message.c @@ -205,7 +205,7 @@ void Msg_FormMsgUsrs (void) /***** Get possible hidden subject and content of the message *****/ Par_GetParHTML ("HiddenSubject",Messages.Subject,Cns_MAX_BYTES_SUBJECT); Par_GetParAndChangeFormat ("HiddenContent",Content,Cns_MAX_BYTES_LONG_TEXT, - Str_TO_TEXT,false); + Str_TO_TEXT,Str_DONT_REMOVE_SPACES); /***** Show a form to compose a message to users *****/ Msg_PutFormMsgUsrs (&Messages,Content); @@ -753,7 +753,7 @@ void Msg_RecMsgFromUsr (void) /* Get body */ Par_GetParAndChangeFormat ("Content",Content,Cns_MAX_BYTES_LONG_TEXT, - Str_DONT_CHANGE,false); + Str_DONT_CHANGE,Str_DONT_REMOVE_SPACES); /* Get parameter that indicates if the message is a reply to a previous message */ if ((IsReply = Par_GetParBool ("IsReply"))) @@ -792,7 +792,7 @@ void Msg_RecMsgFromUsr (void) { /* Show the form again, with the subject and the message filled */ Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT, - Content,Cns_MAX_BYTES_LONG_TEXT,true); + Content,Cns_MAX_BYTES_LONG_TEXT,Str_REMOVE_SPACES); Msg_PutFormMsgUsrs (&Messages,Content); return; } @@ -813,7 +813,7 @@ void Msg_RecMsgFromUsr (void) /***** Loop over the list Gbl.Usrs.Selected.List[Rol_UNK], that holds the list of the recipients, creating a received message for each recipient *****/ Str_ChangeFormat (Str_FROM_FORM,Str_TO_RIGOROUS_HTML, - Content,Cns_MAX_BYTES_LONG_TEXT,false); + Content,Cns_MAX_BYTES_LONG_TEXT,Str_DONT_REMOVE_SPACES); Ptr = Gbl.Usrs.Selected.List[Rol_UNK]; NumRecipients = 0; while (*Ptr) diff --git a/swad_notice.c b/swad_notice.c index b32498ae..0f333ca3 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -148,7 +148,7 @@ void Not_ReceiveNotice (void) /***** Get the text of the notice *****/ Par_GetParAndChangeFormat ("Content",Content,Cns_MAX_BYTES_TEXT, - Str_TO_RIGOROUS_HTML,true); + Str_TO_RIGOROUS_HTML,Str_REMOVE_SPACES); /***** Create a new notice in database *****/ NotCod = Not_DB_InsertNotice (Content); diff --git a/swad_parameter.c b/swad_parameter.c index 57ae672c..54957861 100644 --- a/swad_parameter.c +++ b/swad_parameter.c @@ -912,7 +912,7 @@ unsigned Par_GetParText (const char *ParName,char *ParValue,size_t MaxBytes) { return Par_GetParAndChangeFormat (ParName,ParValue,MaxBytes, Str_TO_TEXT, - true); // Remove leading and trailing spaces + Str_REMOVE_SPACES); } /*****************************************************************************/ @@ -970,7 +970,7 @@ bool Par_GetParBool (const char *ParName) unsigned Par_GetParHTML (const char *ParName,char *ParValue,size_t MaxBytes) { return Par_GetParAndChangeFormat (ParName,ParValue,MaxBytes, - Str_TO_HTML,true); + Str_TO_HTML,Str_REMOVE_SPACES); } /*****************************************************************************/ @@ -984,7 +984,7 @@ unsigned Par_GetParMultiToText (const char *ParName,char *ParValue,size_t MaxByt ParValue,MaxBytes,NULL); Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT, - ParValue,MaxBytes,true); + ParValue,MaxBytes,Str_REMOVE_SPACES); return NumTimes; } @@ -994,7 +994,8 @@ unsigned Par_GetParMultiToText (const char *ParName,char *ParValue,size_t MaxByt // Return the number of parameters found unsigned Par_GetParAndChangeFormat (const char *ParName,char *ParValue,size_t MaxBytes, - Str_ChangeTo_t ChangeTo,bool RemoveLeadingAndTrailingSpaces) + Str_ChangeTo_t ChangeTo, + Str_RemoveSpaces_t RemoveLeadingAndTrailingSpaces) { unsigned NumTimes = Par_GetPar (Par_PARAM_SINGLE,ParName, ParValue,MaxBytes,NULL); diff --git a/swad_parameter.h b/swad_parameter.h index b747e096..41de43c5 100644 --- a/swad_parameter.h +++ b/swad_parameter.h @@ -91,7 +91,8 @@ bool Par_GetParBool (const char *ParName); unsigned Par_GetParHTML (const char *ParName,char *ParValue,size_t MaxBytes); unsigned Par_GetParMultiToText (const char *ParName,char *ParValue,size_t MaxBytes); unsigned Par_GetParAndChangeFormat (const char *ParName,char *ParValue,size_t MaxBytes, - Str_ChangeTo_t ChangeTo,bool RemoveLeadingAndTrailingSpaces); + Str_ChangeTo_t ChangeTo, + Str_RemoveSpaces_t RemoveLeadingAndTrailingSpaces); bool Par_GetNextStrUntilSeparParMult (const char **StrSrc,char *StrDst,size_t LongMax); bool Par_GetNextStrUntilComma (const char **StrSrc,char *StrDst,size_t LongMax); diff --git a/swad_program.c b/swad_program.c index 3227d549..e8aded5c 100644 --- a/swad_program.c +++ b/swad_program.c @@ -689,7 +689,7 @@ static void Prg_WriteItemText (long ItmCod,bool IsHidden) /* Text */ Prg_DB_GetItemTxt (ItmCod,Txt); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML + Txt,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links HTM_DIV_Begin ("class=\"PAR PRG_TXT_%s%s\"", The_GetSuffix (), diff --git a/swad_project.c b/swad_project.c index 4aa78aac..430e056e 100644 --- a/swad_project.c +++ b/swad_project.c @@ -1786,7 +1786,8 @@ static void Prj_ShowReviewStatus (struct Prj_Projects *Projects, { /* Change text format */ Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Projects->Prj.Review.Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML + Projects->Prj.Review.Txt,Cns_MAX_BYTES_TEXT, + Str_DONT_REMOVE_SPACES); switch (Projects->View) { case Prj_PRINT_ONE_PROJECT: @@ -2280,7 +2281,7 @@ static void Prj_ShowTxtField (const struct Prj_Projects *Projects, /***** Change text format *****/ Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - TxtField,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML + TxtField,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); switch (Projects->View) { case Prj_LIST_PROJECTS: @@ -2628,7 +2629,7 @@ static void Prj_ShowTableAllProjectsTxtField (struct Prj_Project *Prj, /***** Change format *****/ Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - TxtField,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML + TxtField,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); /***** Write text *****/ HTM_TD_Begin ("class=\"LT %s_%s %s\"", @@ -4565,7 +4566,8 @@ static void Prj_ShowRubricsOfType (struct Prj_Projects *Projects, HTM_TD_Begin ("colspan=\"8\" class=\"LT PAR DAT_%s %s\"", The_GetSuffix (),The_GetColorRows ()); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Rubric.Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML + Rubric.Txt,Cns_MAX_BYTES_TEXT, + Str_DONT_REMOVE_SPACES); ALn_InsertLinks (Rubric.Txt,Cns_MAX_BYTES_TEXT,60); // Insert links HTM_Txt (Rubric.Txt); HTM_TD_End (); diff --git a/swad_question.c b/swad_question.c index ce8015de..6fb4c3f2 100644 --- a/swad_question.c +++ b/swad_question.c @@ -684,7 +684,8 @@ void Qst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback) Err_NotEnoughMemoryExit (); Str_Copy (FeedbackRigorousHTML,Feedback,FeedbackLength); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - FeedbackRigorousHTML,FeedbackLength,false); + FeedbackRigorousHTML,FeedbackLength, + Str_DONT_REMOVE_SPACES); /***** Write the feedback *****/ HTM_DIV_Begin ("class=\"%s_%s\"", @@ -1692,7 +1693,8 @@ void Qst_ChangeFormatAnswersText (struct Qst_Question *Question) if (Question->Answer.Options[NumOpt].Text[0]) Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Question->Answer.Options[NumOpt].Text, - Qst_MAX_BYTES_ANSWER_OR_FEEDBACK,false); + Qst_MAX_BYTES_ANSWER_OR_FEEDBACK, + Str_DONT_REMOVE_SPACES); } void Qst_ChangeFormatAnswersFeedback (struct Qst_Question *Question) @@ -1708,7 +1710,8 @@ void Qst_ChangeFormatAnswersFeedback (struct Qst_Question *Question) if (Question->Answer.Options[NumOpt].Feedback[0]) Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Question->Answer.Options[NumOpt].Feedback, - Qst_MAX_BYTES_ANSWER_OR_FEEDBACK,false); + Qst_MAX_BYTES_ANSWER_OR_FEEDBACK, + Str_DONT_REMOVE_SPACES); } /*****************************************************************************/ @@ -2699,7 +2702,8 @@ void Qst_GetQstFromForm (struct Qst_Question *Question) if (Question->Tags.Txt[NumTag][0]) { Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT, - Question->Tags.Txt[NumTag],Tag_MAX_BYTES_TAG,true); + Question->Tags.Txt[NumTag],Tag_MAX_BYTES_TAG, + Str_REMOVE_SPACES); /* Check if not repeated */ for (NumTagRead = 0; NumTagRead < NumTag; diff --git a/swad_question_import.c b/swad_question_import.c index c3b18d29..7f466bd9 100644 --- a/swad_question_import.c +++ b/swad_question_import.c @@ -565,7 +565,8 @@ static void QstImp_ImportQuestionsFromXMLBuffer (const char *XMLBuffer) /* Convert stem from text to HTML (in database stem is stored in HTML) */ Str_Copy (Question.Stem,StemElem->Content,Cns_MAX_BYTES_TEXT); Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML, - Question.Stem,Cns_MAX_BYTES_TEXT,true); + Question.Stem,Cns_MAX_BYTES_TEXT, + Str_REMOVE_SPACES); } break; // Only first element "stem" } @@ -581,7 +582,8 @@ static void QstImp_ImportQuestionsFromXMLBuffer (const char *XMLBuffer) /* Convert feedback from text to HTML (in database feedback is stored in HTML) */ Str_Copy (Question.Feedback,FeedbackElem->Content,Cns_MAX_BYTES_TEXT); Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML, - Question.Feedback,Cns_MAX_BYTES_TEXT,true); + Question.Feedback,Cns_MAX_BYTES_TEXT, + Str_REMOVE_SPACES); } break; // Only first element "feedback" } @@ -772,7 +774,8 @@ static void QstImp_GetAnswerFromXML (struct XMLElement *AnswerElem, /* Convert answer from text to HTML (in database answer text is stored in HTML) */ Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML, Question->Answer.Options[NumOpt].Text, - Qst_MAX_BYTES_ANSWER_OR_FEEDBACK,true); + Qst_MAX_BYTES_ANSWER_OR_FEEDBACK, + Str_REMOVE_SPACES); } break; // Only first element "text" } @@ -791,7 +794,8 @@ static void QstImp_GetAnswerFromXML (struct XMLElement *AnswerElem, /* Convert feedback from text to HTML (in database answer feedback is stored in HTML) */ Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML, Question->Answer.Options[NumOpt].Feedback, - Qst_MAX_BYTES_ANSWER_OR_FEEDBACK,true); + Qst_MAX_BYTES_ANSWER_OR_FEEDBACK, + Str_REMOVE_SPACES); } break; // Only first element "feedback" } @@ -987,7 +991,8 @@ static void QstImp_WriteRowImportedQst (struct XMLElement *StemElem, Str_Copy (AnswerText,Question->Answer.Options[NumOpt].Text, AnswerTextLength); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - AnswerText,AnswerTextLength,false); + AnswerText,AnswerTextLength, + Str_DONT_REMOVE_SPACES); /* Convert the feedback, that is in HTML, to rigorous HTML */ AnswerFeedbackLength = 0; @@ -1003,7 +1008,8 @@ static void QstImp_WriteRowImportedQst (struct XMLElement *StemElem, Question->Answer.Options[NumOpt].Feedback, AnswerFeedbackLength); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - AnswerFeedback,AnswerFeedbackLength,false); + AnswerFeedback,AnswerFeedbackLength, + Str_DONT_REMOVE_SPACES); } HTM_TR_Begin (NULL); diff --git a/swad_record.c b/swad_record.c index 52348a39..55a26e60 100644 --- a/swad_record.c +++ b/swad_record.c @@ -1754,7 +1754,8 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView, { Str_Copy (Text,row[0],sizeof (Text)); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Text,Cns_MAX_BYTES_TEXT,false); + Text,Cns_MAX_BYTES_TEXT, + Str_DONT_REMOVE_SPACES); HTM_Txt (Text); } else @@ -3337,8 +3338,9 @@ static void Rec_ShowComments (struct Usr_Data *UsrDat,bool ShowData,bool PutForm } else if (UsrDat->Comments[0]) { - Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, // Convert from HTML to rigorous HTML - UsrDat->Comments,Cns_MAX_BYTES_TEXT,false); + Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, + UsrDat->Comments,Cns_MAX_BYTES_TEXT, + Str_DONT_REMOVE_SPACES); HTM_Txt (UsrDat->Comments); } } diff --git a/swad_rubric.c b/swad_rubric.c index 744e9aeb..ac2b91a4 100644 --- a/swad_rubric.c +++ b/swad_rubric.c @@ -441,7 +441,8 @@ void Rub_ShowRubricMainData (struct Rub_Rubrics *Rubrics, else HTM_TD_Begin ("class=\"LT %s\"",The_GetColorRows ()); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Rubrics->Rubric.Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML + Rubrics->Rubric.Txt,Cns_MAX_BYTES_TEXT, + Str_DONT_REMOVE_SPACES); ALn_InsertLinks (Rubrics->Rubric.Txt,Cns_MAX_BYTES_TEXT,60); // Insert links HTM_DIV_Begin ("class=\"PAR DAT_%s\"",The_GetSuffix ()); HTM_Txt (Rubrics->Rubric.Txt); diff --git a/swad_string.c b/swad_string.c index 745c0630..b6777a24 100644 --- a/swad_string.c +++ b/swad_string.c @@ -724,7 +724,8 @@ For example the string "Nueva++de+San+Ant%F3n" #define Str_MAX_BYTES_SPECIAL_CHAR (256 - 1) void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo, - char *Str,size_t MaxLengthStr,bool RemoveLeadingAndTrailingSpaces) + char *Str,size_t MaxLengthStr, + Str_RemoveSpaces_t RemoveLeadingAndTrailingSpaces) { char *StrDst; char *PtrSrc; @@ -1185,7 +1186,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo, free (StrDst); } - if (RemoveLeadingAndTrailingSpaces) + if (RemoveLeadingAndTrailingSpaces == Str_REMOVE_SPACES) { /***** Remove leading spaces *****/ Str_RemoveLeadingSpacesHTML (Str); diff --git a/swad_string.h b/swad_string.h index 40038178..04c20a68 100644 --- a/swad_string.h +++ b/swad_string.h @@ -78,6 +78,13 @@ typedef enum Str_TO_MARKDOWN, } Str_ChangeTo_t; +typedef enum + { + Str_DONT_REMOVE_SPACES, + Str_REMOVE_SPACES, + } Str_RemoveSpaces_t; + + /*****************************************************************************/ /***************************** Public prototypes ****************************/ /*****************************************************************************/ @@ -106,7 +113,8 @@ void Str_SetDecimalPointToLocal (void); void Str_AddStrToQuery (char *Query,const char *Str,size_t SizeOfQuery); void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo, - char *Str,size_t MaxLengthStr,bool RemoveLeadingAndTrailingSpaces); + char *Str,size_t MaxLengthStr, + Str_RemoveSpaces_t RemoveLeadingAndTrailingSpaces); void Str_RemoveLeadingSpacesHTML (char *Str); void Str_RemoveTrailingSpacesHTML (char *Str); void Str_RemoveLeadingZeros (char *Str); diff --git a/swad_survey.c b/swad_survey.c index ea2d5b20..a0a8bccb 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -647,7 +647,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys, /* Text of the survey */ Svy_DB_GetSurveyTxt (Surveys->Svy.SvyCod,Txt); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML + Txt,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links HTM_DIV_Begin ("class=\"PAR %s_%s\"", Surveys->Svy.Status.Hidden ? "DAT_LIGHT" : @@ -2881,7 +2881,7 @@ static void Svy_WriteQstStem (const char *Stem) Err_NotEnoughMemoryExit (); Str_Copy (HeadingRigorousHTML,Stem,Length); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - HeadingRigorousHTML,Length,false); + HeadingRigorousHTML,Length,Str_DONT_REMOVE_SPACES); /* Write the stem */ HTM_Txt (HeadingRigorousHTML); @@ -2935,7 +2935,8 @@ static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy, Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],Svy_MAX_BYTES_ANSWER); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - SvyQst->AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER,false); + SvyQst->AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER, + Str_DONT_REMOVE_SPACES); /* Selectors and label with the letter of the answer */ HTM_TR_Begin (NULL); @@ -3305,7 +3306,7 @@ static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod) /* Get possible parameter with the user's comment */ snprintf (ParName,sizeof (ParName),"Com%010u",(unsigned) QstCod); Par_GetParAndChangeFormat (ParName,Comments,Cns_MAX_BYTES_TEXT, - Str_TO_RIGOROUS_HTML,true); + Str_TO_RIGOROUS_HTML,Str_REMOVE_SPACES); if (Comments[0]) Svy_DB_CreateComments (QstCod,Comments); } diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index aa0570d0..543b1a91 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -779,7 +779,7 @@ static long TmlCom_ReceiveComm (void) /***** Get the content of the comment *****/ Par_GetParAndChangeFormat ("Txt",Content.Txt,Cns_MAX_BYTES_LONG_TEXT, - Str_TO_RIGOROUS_HTML,true); + Str_TO_RIGOROUS_HTML,Str_REMOVE_SPACES); /***** Initialize image *****/ Med_MediaConstructor (&Content.Media); diff --git a/swad_timeline_post.c b/swad_timeline_post.c index 0f6988e2..aacb90a5 100644 --- a/swad_timeline_post.c +++ b/swad_timeline_post.c @@ -310,7 +310,7 @@ static long TmlPst_ReceivePost (void) /***** Get the content of the new post *****/ Par_GetParAndChangeFormat ("Txt",Content.Txt,Cns_MAX_BYTES_LONG_TEXT, - Str_TO_RIGOROUS_HTML,true); + Str_TO_RIGOROUS_HTML,Str_REMOVE_SPACES); /***** Initialize image *****/ Med_MediaConstructor (&Content.Media); diff --git a/swad_user.c b/swad_user.c index 8c96e974..3ecda3cb 100644 --- a/swad_user.c +++ b/swad_user.c @@ -2436,7 +2436,7 @@ static void Usr_WriteRowStdAllData (struct Usr_Data *UsrDat,char *GroupNames) row = mysql_fetch_row (mysql_res); Str_Copy (Text,row[0],sizeof (Text) - 1); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Text,Cns_MAX_BYTES_TEXT,false); // Se convierte of HTML a HTML respetuoso + Text,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); } else Text[0] = '\0'; @@ -3110,7 +3110,8 @@ void Usr_GetListsSelectedEncryptedUsrsCods (struct Usr_SelectedUsrs *SelectedUsr Ses_DB_GetPar (ParName,SelectedUsrs->List[Rol_UNK], Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT,SelectedUsrs->List[Rol_UNK], - Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS,true); + Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS, + Str_REMOVE_SPACES); } else Par_GetParMultiToText (ParName,SelectedUsrs->List[Rol_UNK],