Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
ui: check spoiler_text against regex filter (mastodon#1635) (mastodon…
Browse files Browse the repository at this point in the history
…#2665)

* ui: check spoiler_text against regex filter (mastodon#1635)

When filtering by regex, also check the spoiler_text if
present.

* ui: concatenate spoiler and content in reducer

Simplifies aa5b03c, clarifies intent of the field
  • Loading branch information
rtucker authored and Gargron committed May 4, 2017
1 parent f9d398e commit 61c3365
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const makeGetStatusIds = () => createSelector([
try {
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'));
showStatus = !regex.test(statusForId.get('reblog') ? statuses.getIn([statusForId.get('reblog'), 'search_index']) : statusForId.get('search_index'));
}
} catch(e) {
// Bad regex, don't affect filters
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/reducers/statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ 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;
const searchContent = [status.spoiler_text, status.content].join(' ').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
normalStatus.search_index = new DOMParser().parseFromString(searchContent, 'text/html').documentElement.textContent;

return state.update(status.id, Immutable.Map(), map => map.mergeDeep(Immutable.fromJS(normalStatus)));
};
Expand Down

0 comments on commit 61c3365

Please sign in to comment.