Skip to content
Snippets Groups Projects
Commit 90760eae authored by abcang's avatar abcang Committed by Eugen
Browse files

fix regex filter (#1845)

* fix regex filter

* fixed br to linebreak and, stlip tags.

* change to send raw content

* changed to unescape in reducer
parent fc34e0e1
No related branches found
No related tags found
No related merge requests found
...@@ -24,8 +24,10 @@ const makeGetStatusIds = () => createSelector([ ...@@ -24,8 +24,10 @@ const makeGetStatusIds = () => createSelector([
if (columnSettings.getIn(['regex', 'body'], '').trim().length > 0) { if (columnSettings.getIn(['regex', 'body'], '').trim().length > 0) {
try { try {
const regex = new RegExp(columnSettings.getIn(['regex', 'body']).trim(), 'i'); if (showStatus) {
showStatus = showStatus && !regex.test(statusForId.get('reblog') ? statuses.getIn([statusForId.get('reblog'), 'content']) : statusForId.get('content')); 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) { } catch(e) {
// Bad regex, don't affect filters // Bad regex, don't affect filters
} }
......
...@@ -48,6 +48,9 @@ const normalizeStatus = (state, status) => { ...@@ -48,6 +48,9 @@ const normalizeStatus = (state, status) => {
normalStatus.reblog = status.reblog.id; normalStatus.reblog = status.reblog.id;
} }
const linebreakComplemented = status.content.replace(/<br \/>/g, '\n').replace(/<\/p><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))); return state.update(status.id, Immutable.Map(), map => map.mergeDeep(Immutable.fromJS(normalStatus)));
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment