From 90760eae4c044817728859e1adf6f57930d83b98 Mon Sep 17 00:00:00 2001 From: abcang Date: Sun, 16 Apr 2017 23:33:38 +0900 Subject: [PATCH] fix regex filter (#1845) * fix regex filter * fixed br to linebreak and, stlip tags. * change to send raw content * changed to unescape in reducer --- .../features/ui/containers/status_list_container.jsx | 6 ++++-- app/assets/javascripts/components/reducers/statuses.jsx | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/components/features/ui/containers/status_list_container.jsx b/app/assets/javascripts/components/features/ui/containers/status_list_container.jsx index f249240d82..4c33f2b61b 100644 --- a/app/assets/javascripts/components/features/ui/containers/status_list_container.jsx +++ b/app/assets/javascripts/components/features/ui/containers/status_list_container.jsx @@ -24,8 +24,10 @@ const makeGetStatusIds = () => createSelector([ if (columnSettings.getIn(['regex', 'body'], '').trim().length > 0) { try { - const regex = new RegExp(columnSettings.getIn(['regex', 'body']).trim(), 'i'); - showStatus = showStatus && !regex.test(statusForId.get('reblog') ? statuses.getIn([statusForId.get('reblog'), 'content']) : statusForId.get('content')); + if (showStatus) { + const regex = new RegExp(columnSettings.getIn(['regex', 'body']).trim(), 'i'); + showStatus = !regex.test(statusForId.get('reblog') ? statuses.getIn([statusForId.get('reblog'), 'unescaped_content']) : statusForId.get('unescaped_content')); + } } catch(e) { // Bad regex, don't affect filters } diff --git a/app/assets/javascripts/components/reducers/statuses.jsx b/app/assets/javascripts/components/reducers/statuses.jsx index ca8fa7a015..2002d22233 100644 --- a/app/assets/javascripts/components/reducers/statuses.jsx +++ b/app/assets/javascripts/components/reducers/statuses.jsx @@ -48,6 +48,9 @@ const normalizeStatus = (state, status) => { normalStatus.reblog = status.reblog.id; } + const linebreakComplemented = status.content.replace(/
/g, '\n').replace(/<\/p>

/g, '\n\n'); + normalStatus.unescaped_content = new DOMParser().parseFromString(linebreakComplemented, 'text/html').documentElement.textContent; + return state.update(status.id, Immutable.Map(), map => map.mergeDeep(Immutable.fromJS(normalStatus))); };