Skip to content

Commit 1924fea

Browse files
committed
Исправление ошибки с регистром ссылок в тэге [url=]
1 parent 147c8b5 commit 1924fea

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

src/parser.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ AParsedBlockList AParser::parseBlocks (const QString& source)
253253
}
254254

255255
// получение тэга
256-
QString tag = data.mid(pos1, pos2 - pos1 + 1).toLower();
256+
QString tag = data.mid(pos1, pos2 - pos1 + 1);
257+
QString ltag = tag.toLower();
257258

258259
current_quote.Data += data.mid(0, pos1);
259260
data.remove(0, pos2 + 1);
@@ -276,7 +277,7 @@ AParsedBlockList AParser::parseBlocks (const QString& source)
276277
{
277278
// поиск открывающего тэга
278279
for (size_t i = 0; i < sizeof(strong_tags) / sizeof(AStrongTag); i++)
279-
if (tag == strong_tags[i].OpenPart)
280+
if (ltag == strong_tags[i].OpenPart)
280281
{
281282
found_tag = &strong_tags[i];
282283
break;
@@ -286,7 +287,7 @@ AParsedBlockList AParser::parseBlocks (const QString& source)
286287
{
287288
// поиск закрывающего тэга
288289
for (size_t i = 0; i < sizeof(strong_tags) / sizeof(AStrongTag); i++)
289-
if (tag == strong_tags[i].ClosePart && strong_tags[i].Type == current_block.Type)
290+
if (ltag == strong_tags[i].ClosePart && strong_tags[i].Type == current_block.Type)
290291
{
291292
found_tag = &strong_tags[i];
292293
break;
@@ -322,12 +323,20 @@ AParsedBlockList AParser::parseBlocks (const QString& source)
322323
// найден простой немонолитный тэг
323324
if (found_tag == NULL)
324325
{
325-
if (tag == "[strike]")
326-
tag = "[s]";
327-
else if (tag == "[/strike]")
328-
tag = "[/s]";
326+
// двойной тэг перечеркивания - приводим к одному
327+
if (ltag == "[strike]")
328+
ltag = "[s]";
329+
else if (ltag == "[/strike]")
330+
ltag = "[/s]";
331+
332+
// специальный случай ссылки - содержимое ссылки не должно менять регистр
333+
if (ltag.indexOf("[url=") == 0)
334+
{
335+
ltag = tag;
336+
ltag.replace(0, 5, "[url=");
337+
}
329338

330-
current_quote.Data += tag;
339+
current_quote.Data += ltag;
331340

332341
// условие выполнится, когда строка заканчивается немонолитным тэгом
333342
if (data.length() == 0)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[url=http://www.youtube.com/watch?v=IJNR2EpS0jw]http://www.youtube.com/watch?v=IJNR2EpS0jw[/url]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
AParsedBlockList
2+
(
3+
[0] = AParsedBlock
4+
(
5+
Type = pbtText
6+
SubType = pbstText
7+
Strings = AQuotedStringList
8+
(
9+
[0] = AQuotedString
10+
(
11+
QuoteLevel = 0
12+
Data = [url=http://www.youtube.com/watch?v=IJNR2EpS0jw]http://www.youtube.com/watch?v=IJNR2EpS0jw[/url]
13+
)
14+
)
15+
)
16+
)

0 commit comments

Comments
 (0)