Review: Needs Fixing

I've done some research in to this. Officially the only code points allowed are:

"
[2]     Char       ::=          #x9 | #xA | #xD | [#x20-#xD7FF] | 
[#xE000-#xFFFD] | [#x10000-#x10FFFF]  /* any Unicode character, excluding the 
surrogate blocks, FFFE, and FFFF. */
"   ( https://www.w3.org/TR/REC-xml/#charsets)

So going on this our regex should be:

re.compile(r'[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]')

we probably should filter out the other code points too.

Its worth noting that REPLACMENT_CHARS_MAP replaces the vertical tab and form 
feed chars with "\n\n" before the CONTROL_CHARS regex filters them out!

So in summary please replace the regex with the one in the inline comment. 
(Note: its not tested)


Diff comments:

> === modified file 'openlp/core/common/__init__.py'
> --- openlp/core/common/__init__.py    2018-02-24 16:10:02 +0000
> +++ openlp/core/common/__init__.py    2018-04-15 14:10:22 +0000
> @@ -44,7 +44,7 @@
>  
>  FIRST_CAMEL_REGEX = re.compile('(.)([A-Z][a-z]+)')
>  SECOND_CAMEL_REGEX = re.compile('([a-z0-9])([A-Z])')
> -CONTROL_CHARS = re.compile(r'[\x00-\x1F\x7F-\x9F]')
> +CONTROL_CHARS = re.compile(r'[\x00-\08\x0E-\x1F\x7F-\x9F]')

CONTROL_CHARS = re.compile(r'[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]')

>  INVALID_FILE_CHARS = re.compile(r'[\\/:\*\?"<>\|\+\[\]%]')
>  IMAGES_FILTER = None
>  REPLACMENT_CHARS_MAP = str.maketrans({'\u2018': '\'', '\u2019': '\'', 
> '\u201c': '"', '\u201d': '"', '\u2026': '...',


-- 
https://code.launchpad.net/~thelinuxguy/openlp/fix-newline-bug/+merge/343277
Your team OpenLP Core is subscribed to branch lp:openlp.

_______________________________________________
Mailing list: https://launchpad.net/~openlp-core
Post to     : openlp-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to