Skip to content

Commit

Permalink
all legal whitespace chars must be skipped when parsing attribute nam…
Browse files Browse the repository at this point in the history
…es in QP
  • Loading branch information
kevinhendricks committed Nov 29, 2023
1 parent 46dbfa3 commit 976dde0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 4 additions & 2 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ pre-2.x.x
- assign menu accelerators P - &Plugins, and K - Chec&kpoints (thank you BeckyEbook)
- add ability to change keyboard focus using keyboard shortcuts or menus
to BookBrowser, Preview, CodeView, ClipsWindow, and TableOfContents Windows
Bug Fixes
- patch Qt6.5.3 to avoid transient child window resize bug on Windows
Bug Fixes
- patch Qt6.5.3 to avoid transient child window resize bug on Windows
- fix QuickParser bug when parseing attribute names not properly ignoreing all legal whitespace


Sigil-2.0.2
Bug Fixes
Expand Down
6 changes: 4 additions & 2 deletions src/Parsers/QuickParser.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/************************************************************************
**
** Copyright (C) 2020-2021 Kevin B. Hendricks, Stratford Ontario
** Copyright (C) 2020-2023 Kevin B. Hendricks, Stratford Ontario
**
** This file is part of Sigil.
**
Expand Down Expand Up @@ -29,6 +29,8 @@
#include "Misc/Utility.h"
#include "Parsers/QuickParser.h"

const QString WHITESPACE_CHARS=" \v\t\n\r\f";

QuickParser::QuickParser(const QString &source, QString default_lang)
: m_source(source),
m_pos(0),
Expand Down Expand Up @@ -261,7 +263,7 @@ int QuickParser::findTarget(const QString &tgt, int p, bool after)

int QuickParser::skipAnyBlanks(const QStringRef &tgt, int p)
{
while((p < tgt.length()) && (tgt.at(p) == ' ')) p++;
while((p < tgt.length()) && (WHITESPACE_CHARS.contains(tgt.at(p)))) p++;
return p;
}

Expand Down
8 changes: 5 additions & 3 deletions src/Resource_Files/plugin_launchers/python/quickparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab

# Copyright (c) 2014-2021 Kevin B. Hendricks, and Doug Massay
# Copyright (c) 2014-2023 Kevin B. Hendricks, and Doug Massay
# Copyright (c) 2014 John Schember
# All rights reserved.
#
Expand Down Expand Up @@ -39,6 +39,8 @@

SPECIAL_HANDLING_TYPES = ['xmlheader', 'doctype', 'comment', 'cdata', 'pi']

WHITESPACE_CHARS = (' ', '\n', '\r', '\f', '\t', '\v')

class QuickXHTMLParser(object):

def __init__(self):
Expand Down Expand Up @@ -109,14 +111,14 @@ def parsetag(self, s):
if ttype is None:
# parse any attributes
while s.find('=', p) != -1 :
while p < n and s[p:p + 1] == ' ' : p += 1
while p < n and s[p:p + 1] in WHITESPACE_CHARS : p += 1
b = p
while p < n and s[p:p + 1] != '=' : p += 1
# attribute names can be mixed case and are in SVG
aname = s[b:p]
aname = aname.rstrip(' ')
p += 1
while p < n and s[p:p + 1] == ' ' : p += 1
while p < n and s[p:p + 1] in WHITESPACE_CHARS : p += 1
if s[p:p + 1] in ('"', "'") :
qt = s[p:p + 1]
p = p + 1
Expand Down

0 comments on commit 976dde0

Please sign in to comment.