mirror of https://github.com/acanas/swad-core.git
Version 21.95.3: May 09, 2022 Fixed bug inserting automatic links. Reported by Javier Fernández Baldomero and others.
This commit is contained in:
parent
0fa596df82
commit
670522e4d6
|
@ -103,9 +103,11 @@ static void ALn_CopySubstring (const struct ALn_Substring *PtrSrc,char **PtrDst)
|
|||
#define ALn_URL_ANCHOR_0 "<a href=\""
|
||||
#define ALn_URL_ANCHOR_1 "\" target=\"_blank\">"
|
||||
#define ALn_URL_ANCHOR_2 "</a>"
|
||||
|
||||
#define ALn_URL_ANCHOR_0_LENGTH (sizeof (ALn_URL_ANCHOR_0) - 1)
|
||||
#define ALn_URL_ANCHOR_1_LENGTH (sizeof (ALn_URL_ANCHOR_1) - 1)
|
||||
#define ALn_URL_ANCHOR_2_LENGTH (sizeof (ALn_URL_ANCHOR_2) - 1)
|
||||
|
||||
#define ALn_URL_ANCHOR_TOTAL_LENGTH (ALn_URL_ANCHOR_0_LENGTH + ALn_URL_ANCHOR_1_LENGTH + ALn_URL_ANCHOR_2_LENGTH)
|
||||
|
||||
static const struct ALn_Substring URLAnchor[3] =
|
||||
|
@ -202,8 +204,9 @@ void ALn_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
|
|||
/* Check if the next char is the start of a nickname */
|
||||
if ((Link->Type = ALn_CheckNickname (&PtrSrc,PrevCh,
|
||||
&Link,&LastLink)) == ALn_LINK_UNKNOWN)
|
||||
{
|
||||
/* The next char is not the start of a URL or a nickname */
|
||||
if (*PtrSrc) // If not end reached
|
||||
{
|
||||
PrevCh = *PtrSrc;
|
||||
PtrSrc++;
|
||||
}
|
||||
|
@ -217,6 +220,7 @@ void ALn_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
|
|||
only if there is enough space available in text *****/
|
||||
TxtLength = strlen (Txt);
|
||||
if (TxtLength + LastLink->LengthAddedUpToHere <= MaxLength)
|
||||
{
|
||||
for (Link = LastLink;
|
||||
Link;
|
||||
Link = Link->Prev)
|
||||
|
@ -241,9 +245,10 @@ void ALn_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
|
|||
/***** Step 1: Move forward the text after the link (URL or nickname)
|
||||
(it's mandatory to do the copy in reverse order
|
||||
to avoid overwriting source) *****/
|
||||
|
||||
PtrSrc = (Link == LastLink) ? Txt + TxtLength :
|
||||
Link->Next->URLorNick.Str - 1,
|
||||
PtrDst = PtrSrc + Link->LengthAddedUpToHere ,
|
||||
Link->Next->URLorNick.Str - 1;
|
||||
PtrDst = PtrSrc + Link->LengthAddedUpToHere;
|
||||
Length = PtrSrc - (Link->URLorNick.Str + Link->URLorNick.Len - 1);
|
||||
for (i = 0;
|
||||
i < Length;
|
||||
|
@ -291,6 +296,7 @@ void ALn_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
|
|||
ALn_CopySubstring (Anchor[0],&PtrDst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
/***** Free memory for anchors *****/
|
||||
|
@ -512,8 +518,10 @@ static ALn_LinkType_t ALn_CheckNickname (char **PtrSrc,char PrevCh,
|
|||
|
||||
if (NickSeemsValid)
|
||||
{
|
||||
/***** Get user's code using nickname *****/
|
||||
/***** Create data for a user *****/
|
||||
Usr_UsrDataConstructor (&UsrDat);
|
||||
|
||||
/***** Get user's code using nickname *****/
|
||||
strncpy (NickWithoutArr,(*Link)->URLorNick.Str + 1,Length);
|
||||
NickWithoutArr[Length] = '\0';
|
||||
if ((UsrDat.UsrCod = Nck_DB_GetUsrCodFromNickname (NickWithoutArr)) > 0)
|
||||
|
@ -580,9 +588,6 @@ static ALn_LinkType_t ALn_CheckNickname (char **PtrSrc,char PrevCh,
|
|||
free (CaptionStr);
|
||||
(*Link)->NickAnchor[2].Len = strlen ((*Link)->NickAnchor[2].Str);
|
||||
|
||||
/***** Free memory used for user's data *****/
|
||||
Usr_UsrDataDestructor (&UsrDat);
|
||||
|
||||
/***** Compute number of bytes added until here *****/
|
||||
(*Link)->LengthAddedUpToHere = (*Link)->Prev ? (*Link)->Prev->LengthAddedUpToHere :
|
||||
0;
|
||||
|
@ -594,6 +599,9 @@ static ALn_LinkType_t ALn_CheckNickname (char **PtrSrc,char PrevCh,
|
|||
/***** Create next link *****/
|
||||
ALn_CreateNextLink (Link,LastLink);
|
||||
}
|
||||
|
||||
/***** Free memory used for user's data *****/
|
||||
Usr_UsrDataDestructor (&UsrDat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -606,10 +606,11 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate
|
|||
|
||||
TODO: Attach pdf files in multimedia.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.95.2 (2022-04-30)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.95.2 (2022-05-09)"
|
||||
#define CSS_FILE "swad21.95.css"
|
||||
#define JS_FILE "swad21.92.js"
|
||||
/*
|
||||
Version 21.95.3: May 09, 2022 Fixed bug inserting automatic links. Reported by Javier Fernández Baldomero and others. (323439 lines)
|
||||
Version 21.95.2: Apr 30, 2022 Fixed issue in most frequent actions. Reported by Pablo Millán Cubero. (323423 lines)
|
||||
Version 21.95.1: Apr 27, 2022 Fixing design of dark theme. (323406 lines)
|
||||
Version 21.95: Apr 27, 2022 Fixing design of dark theme. (323404 lines)
|
||||
|
|
|
@ -249,6 +249,13 @@ void Med_GetMediaDataByCod (struct Med_Media *Media)
|
|||
unsigned NumRows;
|
||||
size_t Length;
|
||||
|
||||
/***** Trivial check: media code should be > 0 *****/
|
||||
if (Media->MedCod <= 0)
|
||||
{
|
||||
Med_ResetMedia (Media);
|
||||
return;
|
||||
}
|
||||
|
||||
/***** Get data of a media from database *****/
|
||||
NumRows = Med_DB_GetMediaDataByCod (&mysql_res,Media->MedCod);
|
||||
|
||||
|
|
|
@ -114,7 +114,10 @@ static void TmlPst_GetPostContent (long PstCod,struct TmlPst_Content *Content)
|
|||
Med_GetMediaDataByCod (&Content->Media);
|
||||
}
|
||||
else
|
||||
{
|
||||
Content->Txt[0] = '\0';
|
||||
Med_ResetMedia (&Content->Media);
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -126,11 +129,14 @@ static void TmlPst_GetPostContent (long PstCod,struct TmlPst_Content *Content)
|
|||
|
||||
static void TmlPst_ShowPostContent (struct TmlPst_Content *Content)
|
||||
{
|
||||
/***** Trivial check *****/
|
||||
if (Content == NULL)
|
||||
Err_ShowErrorAndExit ("Wrong content.");
|
||||
|
||||
/***** Write content text *****/
|
||||
if (Content->Txt[0])
|
||||
{
|
||||
HTM_DIV_Begin ("class=\"Tml_TXT Tml_TXT_%s\"",
|
||||
The_GetSuffix ());
|
||||
HTM_DIV_Begin ("class=\"Tml_TXT Tml_TXT_%s\"",The_GetSuffix ());
|
||||
Msg_WriteMsgContent (Content->Txt,true,false);
|
||||
HTM_DIV_End ();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue