← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol/openlp/bug-825983 into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol/openlp/bug-825983 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #825979 in OpenLP: "Spellchecker for Service Notes"
  https://bugs.launchpad.net/openlp/+bug/825979
  Bug #825983 in OpenLP: "Service Item/Print Notes Text needs to be escaped"
  https://bugs.launchpad.net/openlp/+bug/825983

For more details, see:
https://code.launchpad.net/~googol/openlp/bug-825983/+merge/71480

Hello,

1) Now the service note dialog has a spellchecker.
2) The formatting tags menu can now be disabled when using a spellchecker because tooltip only seem to interpret the "standard" html (like strong, but not something like <span style="-webkit-text-fill-color:green"><span>).
3) Escape text (service notes and service print).
-- 
https://code.launchpad.net/~googol/openlp/bug-825983/+merge/71480
Your team OpenLP Core is requested to review the proposed merge of lp:~googol/openlp/bug-825983 into lp:openlp.
=== modified file 'openlp/core/lib/spelltextedit.py'
--- openlp/core/lib/spelltextedit.py	2011-07-30 07:34:37 +0000
+++ openlp/core/lib/spelltextedit.py	2011-08-14 13:24:24 +0000
@@ -48,9 +48,10 @@
     """
     Spell checking widget based on QPlanTextEdit.
     """
-    def __init__(self, *args):
+    def __init__(self, parent=None, formattingTagsAllowed=True):
         global ENCHANT_AVAILABLE
-        QtGui.QPlainTextEdit.__init__(self, *args)
+        QtGui.QPlainTextEdit.__init__(self, parent)
+        self.formattingTagsAllowed = formattingTagsAllowed
         # Default dictionary based on the current locale.
         if ENCHANT_AVAILABLE:
             try:
@@ -110,16 +111,17 @@
                     spell_menu.addAction(action)
                 # Only add the spelling suggests to the menu if there are
                 # suggestions.
-                if len(spell_menu.actions()):
+                if spell_menu.actions():
                     popupMenu.insertMenu(popupMenu.actions()[0], spell_menu)
         tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
             'Formatting Tags'))
-        for html in FormattingTags.get_html_tags():
-            action = SpellAction(html[u'desc'], tagMenu)
-            action.correct.connect(self.htmlTag)
-            tagMenu.addAction(action)
-        popupMenu.insertSeparator(popupMenu.actions()[0])
-        popupMenu.insertMenu(popupMenu.actions()[0], tagMenu)
+        if self.formattingTagsAllowed:
+            for html in FormattingTags.get_html_tags():
+                action = SpellAction(html[u'desc'], tagMenu)
+                action.correct.connect(self.htmlTag)
+                tagMenu.addAction(action)
+            popupMenu.insertSeparator(popupMenu.actions()[0])
+            popupMenu.insertMenu(popupMenu.actions()[0], tagMenu)
         popupMenu.exec_(event.globalPos())
 
     def setLanguage(self, action):

=== modified file 'openlp/core/ui/printservicedialog.py'
--- openlp/core/ui/printservicedialog.py	2011-06-26 16:15:13 +0000
+++ openlp/core/ui/printservicedialog.py	2011-08-14 13:24:24 +0000
@@ -108,7 +108,7 @@
         self.footerLabel = QtGui.QLabel(self.optionsWidget)
         self.footerLabel.setObjectName(u'footerLabel')
         self.optionsLayout.addWidget(self.footerLabel)
-        self.footerTextEdit = SpellTextEdit(self.optionsWidget)
+        self.footerTextEdit = SpellTextEdit(self.optionsWidget, False)
         self.footerTextEdit.setObjectName(u'footerTextEdit')
         self.optionsLayout.addWidget(self.footerTextEdit)
         self.optionsGroupBox = QtGui.QGroupBox()

=== modified file 'openlp/core/ui/printserviceform.py'
--- openlp/core/ui/printserviceform.py	2011-07-16 09:00:30 +0000
+++ openlp/core/ui/printserviceform.py	2011-08-14 13:24:24 +0000
@@ -24,6 +24,7 @@
 # with this program; if not, write to the Free Software Foundation, Inc., 59  #
 # Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
 ###############################################################################
+import cgi
 import datetime
 import os
 
@@ -183,7 +184,7 @@
         self._addElement(u'style', custom_css, html_data.head,
             attribute=(u'type', u'text/css'))
         self._addElement(u'body', parent=html_data)
-        self._addElement(u'h1', unicode(self.titleLineEdit.text()),
+        self._addElement(u'h1', cgi.escape(unicode(self.titleLineEdit.text())),
             html_data.body, classId=u'serviceTitle')
         for index, item in enumerate(self.serviceManager.serviceItems):
             self._addPreviewItem(html_data.body, item[u'service_item'], index)
@@ -193,8 +194,9 @@
                 classId=u'customNotes')
             self._addElement(u'span', translate('OpenLP.ServiceManager',
                 'Custom Service Notes: '), div, classId=u'customNotesTitle')
-            self._addElement(u'span', self.footerTextEdit.toPlainText(), div,
-                classId=u'customNotesText')
+            self._addElement(u'span',
+                cgi.escape(self.footerTextEdit.toPlainText()),
+                div, classId=u'customNotesText')
         self.document.setHtml(html.tostring(html_data))
         self.previewWidget.updatePreview()
 
@@ -204,8 +206,8 @@
         item_title = self._addElement(u'h2', parent=div, classId=u'itemTitle')
         self._addElement(u'img', parent=item_title,
             attribute=(u'src', item.icon))
-        self._addElement(u'span', u'&nbsp;' + item.get_display_title(),
-            item_title)
+        self._addElement(u'span',
+            u'&nbsp;' + cgi.escape(item.get_display_title()), item_title)
         if self.slideTextCheckBox.isChecked():
             # Add the text of the service item.
             if item.is_text():
@@ -230,8 +232,9 @@
             foot_text = item.foot_text
             foot_text = foot_text.partition(u'<br>')[2]
             if foot_text:
-                foot = self._addElement(u'div', foot_text, parent=div,
-                    classId=u'itemFooter')
+                foot_text = cgi.escape(foot_text.replace(u'<br>', u'\n'))
+                self._addElement(u'div', foot_text.replace(u'\n', u'<br>'),
+                    parent=div, classId=u'itemFooter')
         # Add service items' notes.
         if self.notesCheckBox.isChecked():
             if item.notes:
@@ -239,8 +242,8 @@
                 self._addElement(u'span',
                     translate('OpenLP.ServiceManager', 'Notes: '), p,
                     classId=u'itemNotesTitle')
-                notes = self._addElement(u'span',
-                    item.notes.replace(u'\n', u'<br>'), p,
+                self._addElement(u'span',
+                    cgi.escape(unicode(item.notes)).replace(u'\n', u'<br>'), p,
                     classId=u'itemNotesText')
         # Add play length of media files.
         if item.is_media() and self.metaDataCheckBox.isChecked():

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2011-08-11 09:20:29 +0000
+++ openlp/core/ui/servicemanager.py	2011-08-14 13:24:24 +0000
@@ -24,6 +24,7 @@
 # with this program; if not, write to the Free Software Foundation, Inc., 59  #
 # Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
 ###############################################################################
+import cgi
 import cPickle
 import logging
 import os
@@ -719,6 +720,9 @@
             self.setModified()
 
     def onStartTimeForm(self):
+        """
+        Opens a dialog to type in service item notes.
+        """
         item = self.findServiceItem()[0]
         self.startTimeForm.item = self.serviceItems[item]
         if self.startTimeForm.exec_():
@@ -957,7 +961,7 @@
             if serviceitem.notes:
                 tips.append(u'<strong>%s: </strong> %s' %
                     (unicode(translate('OpenLP.ServiceManager', 'Notes')),
-                    unicode(serviceitem.notes)))
+                    cgi.escape(unicode(serviceitem.notes))))
             if item[u'service_item'] \
                 .is_capable(ItemCapabilities.AllowsVariableStartTime):
                 tips.append(item[u'service_item'].get_media_time())

=== modified file 'openlp/core/ui/servicenoteform.py'
--- openlp/core/ui/servicenoteform.py	2011-06-28 19:24:29 +0000
+++ openlp/core/ui/servicenoteform.py	2011-08-14 13:24:24 +0000
@@ -27,7 +27,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import translate
+from openlp.core.lib import translate, SpellTextEdit
 from openlp.core.lib.ui import create_accept_reject_button_box
 
 class ServiceNoteForm(QtGui.QDialog):
@@ -52,7 +52,7 @@
         self.dialogLayout.setContentsMargins(8, 8, 8, 8)
         self.dialogLayout.setSpacing(8)
         self.dialogLayout.setObjectName(u'verticalLayout')
-        self.textEdit = QtGui.QTextEdit(self)
+        self.textEdit = SpellTextEdit(self, False)
         self.textEdit.setObjectName(u'textEdit')
         self.dialogLayout.addWidget(self.textEdit)
         self.dialogLayout.addWidget(create_accept_reject_button_box(self))


Follow ups