From 6a8fcf6f33ce32a7c869580b1eb9b76ce2fc2e53 Mon Sep 17 00:00:00 2001 From: William Kennedy Date: Wed, 3 Nov 2021 04:27:12 +0000 Subject: [PATCH] HTML tag and attribute matcher (#15091) * HTML tag and attribute matcher This regex was designed for the following matches. It should ignore plain text
" target="_blank" rel="noopener me" class="profile-header__meta__item p-1"> class="crayons-layout crayons-layout--limited-l crayons-layout--2-cols crayons-layout--2-cols--1-2 pt-4 m:pt-0" href="javascript:void(0);" id="asdf" class="sas" data-profile-user-id="asdf">sads data-tag="" * added rails sanitizer * removed swap file * Update bin/untranslated_erb Co-authored-by: Michael Kohl * revert gitignore Co-authored-by: Michael Kohl --- bin/untranslated_erb | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/bin/untranslated_erb b/bin/untranslated_erb index 850586925..d341443f9 100755 --- a/bin/untranslated_erb +++ b/bin/untranslated_erb @@ -1,7 +1,9 @@ #!/usr/bin/env ruby +require 'rails-html-sanitizer' + class I18nExtractor ERB_TAG = /<%(.*?)%>/ - HTML_TAG = /<(.*?)>/ + HTML_TAG = /<[^>]*>|<\/[^>]*>|[^>]*\/>|\".+">|">|<\w+(.+|)|.+="(.+)|"/ SEPERATOR = '_@@@_' SKIP_TAGS = [[/