]> cat aescling's git repositories - mastodon.git/commitdiff
fix regex filter (#1845)
authorabcang <abcang1015@gmail.com>
Sun, 16 Apr 2017 14:33:38 +0000 (23:33 +0900)
committerEugen <eugen@zeonfederated.com>
Sun, 16 Apr 2017 14:33:38 +0000 (16:33 +0200)
* fix regex filter

* fixed br to linebreak and, stlip tags.

* change to send raw content

* changed to unescape in reducer

app/assets/javascripts/components/features/ui/containers/status_list_container.jsx
app/assets/javascripts/components/reducers/statuses.jsx

index f249240d827a61b47b0b2cf5c84cd82db9b0bf7b..4c33f2b61b8f6ffc429951f872af50159e01f2c5 100644 (file)
@@ -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
     }
index ca8fa7a015b9049b5d45fe41d653439a43f99400..2002d22233903adea7998f4925513eecf4a7a8b7 100644 (file)
@@ -48,6 +48,9 @@ const normalizeStatus = (state, status) => {
     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)));
 };