Bugfix while displaying content of textarea-entered text (Strings with format=String.TEXT): for displaying again textarea content, I replaced 'backslash n' with html br tags, but in some cases carriage returns are stored as a sequence of 'backslah r' and 'backslah n' chars. In this case, 'backslash r' chars were left alone in the HTML page, producing sometimes strange behaviour within the browser.
This commit is contained in:
parent
3fc5bc8418
commit
39321b2d38
|
@ -1 +1 @@
|
|||
0.6.3
|
||||
0.6.4
|
||||
|
|
|
@ -1162,6 +1162,18 @@ class BaseMixin:
|
|||
if '-' in res: res = res[:res.find('-')]
|
||||
return res
|
||||
|
||||
def formatText(self, text, format='html'):
|
||||
'''Produces a representation of p_text into the desired p_format, which
|
||||
is 'html' by default.'''
|
||||
if format in ('html', 'xhtml'):
|
||||
res = text.replace('\r\n', '<br/>').replace('\n', '<br/>')
|
||||
elif format == 'js':
|
||||
res = text.replace('\r\n', '').replace('\n', '')
|
||||
res = res.replace("'", "\\'")
|
||||
else:
|
||||
res = text
|
||||
return res
|
||||
|
||||
def translate(self, label, mapping={}, domain=None, default=None,
|
||||
language=None, format='html'):
|
||||
'''Translates a given p_label into p_domain with p_mapping.'''
|
||||
|
@ -1196,11 +1208,7 @@ class BaseMixin:
|
|||
if not res: res = label
|
||||
else:
|
||||
# Perform replacements, according to p_format.
|
||||
if format == 'html':
|
||||
res = res.replace('\r\n', '<br/>').replace('\n', '<br/>')
|
||||
elif format == 'js':
|
||||
res = res.replace('\r\n', '').replace('\n', '')
|
||||
res = res.replace("'", "\\'")
|
||||
res = self.formatText(res, format)
|
||||
# Perform variable replacements
|
||||
for name, repl in mapping.iteritems():
|
||||
res = res.replace('${%s}' % name, repl)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</span>
|
||||
<tal:formattedString condition="python: fmt not in (0, 3)">
|
||||
<span tal:condition="python: value and (fmt == 1)"
|
||||
tal:replace="structure python: value.replace('\n', '<br>')"/>
|
||||
tal:replace="structure python: contextObj.formatText(value, format='html')"/>
|
||||
<span tal:condition="python: value and (fmt == 2)" tal:replace="structure value"/>
|
||||
</tal:formattedString>
|
||||
</metal:view>
|
||||
|
|
|
@ -378,7 +378,7 @@ class AbstractWrapper:
|
|||
self.o.reindexObject()
|
||||
|
||||
def export(self, at='string', format='xml', include=None, exclude=None):
|
||||
'''Creates an "exportable" version of this object. p_format is XML by
|
||||
'''Creates an "exportable" version of this object. p_format is "xml" by
|
||||
default, but can also be "csv". If p_format is:
|
||||
* "xml", if p_at is "string", this method returns the XML version,
|
||||
without the XML prologue. Else, (a) if not p_at, the XML
|
||||
|
@ -427,4 +427,9 @@ class AbstractWrapper:
|
|||
p_data must be a dictionary whose keys are field names (strings) and
|
||||
whose values are the previous field values.'''
|
||||
self.o.addDataChange(data)
|
||||
|
||||
def formatText(self, text, format='html'):
|
||||
'''Produces a representation of p_text into the desired p_format, which
|
||||
is 'html' by default.'''
|
||||
return self.o.formatText(text, format)
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -80,12 +80,12 @@ class Converter:
|
|||
'''Returns the absolute path of the input file. In fact, it returns a
|
||||
tuple with some URL version of the path for OO as the first element
|
||||
and the absolute path as the second element.'''
|
||||
import uno
|
||||
import unohelper
|
||||
if not os.path.exists(docPath) and not os.path.isfile(docPath):
|
||||
raise ConverterError(DOC_NOT_FOUND % docPath)
|
||||
docAbsPath = os.path.abspath(docPath)
|
||||
# Return one path for OO, one path for me.
|
||||
return uno.systemPathToFileUrl(docAbsPath), docAbsPath
|
||||
return unohelper.systemPathToFileUrl(docAbsPath), docAbsPath
|
||||
|
||||
def getResultFilter(self):
|
||||
'''Based on the result type, identifies which OO filter to use for the
|
||||
|
@ -110,7 +110,7 @@ class Converter:
|
|||
different extension:
|
||||
<inputFileName>.<resultType>
|
||||
'''
|
||||
import uno
|
||||
import unohelper
|
||||
baseName = os.path.splitext(self.docPath)[0]
|
||||
if self.resultType != self.inputType:
|
||||
res = '%s.%s' % (baseName, self.resultType)
|
||||
|
@ -121,7 +121,7 @@ class Converter:
|
|||
f.write('Hello')
|
||||
f.close()
|
||||
os.remove(res)
|
||||
return uno.systemPathToFileUrl(res)
|
||||
return unohelper.systemPathToFileUrl(res)
|
||||
except (OSError, IOError), ioe:
|
||||
raise ConverterError(CANNOT_WRITE_RESULT % (res, ioe))
|
||||
|
||||
|
|
Loading…
Reference in a new issue