Skip to content

Commit 05962ef

Browse files
authored
Merge pull request #151 from mitre-attack/fix/#150-contributors-search
Removing unicode characters from search index
2 parents 7c14618 + 9c3b0b5 commit 05962ef

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
### Fixes
4444
- added internet explorer for sub-techniques matrix. Improved behavior of sub-techniques matrix in Edge browser. See issue [#114](https://github.com/mitre-attack/attack-website/issues/114).
4545
- fixed bug where sidenav wouldn't open the correct tactic when opening the sub-technique of a technique. See issue [#78](https://github.com/mitre-attack/attack-website/issues/78).
46+
- fixed bug where contributors wouldn't appear in search. See issue[#150](https://github.com/mitre-attack/attack-website/issues/150).
4647

4748
## ATT&CK Website version 2.0
4849
### New Features

modules/search.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def generate_index():
2727
if not os.path.isdir(config.web_directory):
2828
os.makedirs(config.web_directory)
2929

30-
json.dump(index, open(os.path.join(config.web_directory, "index.json"), mode="w", encoding="utf8"), indent=2)
30+
json.dump(index, open(os.path.join(config.web_directory, "index.json"), mode="w", encoding="utf-8"), indent=2)
3131

3232
if (config.subdirectory):
3333
# update search base url to subdirectory
@@ -50,9 +50,19 @@ def skipline(line):
5050
if skip in line: return True
5151
return False
5252

53+
def clean_line(line):
54+
"""clean unicode spaces from line"""
55+
# Replace unicode spaces
56+
line = line.replace(u"\u00a0", " ")
57+
line = line.replace(u"\u202f", " ")
58+
line = line.replace(" ", " ")
59+
line = line.replace("&nbsp", " ")
60+
61+
return line
62+
5363
def clean(filepath):
5464
"""clean the file of all HTML tags and unnecessary data"""
55-
f = open(filepath, mode="r", encoding="utf8")
65+
f = open(filepath, mode="r", encoding="utf-8")
5666
lines = f.readlines()
5767
f.close()
5868

@@ -61,8 +71,8 @@ def clean(filepath):
6171
skipindex = False
6272
indexing = False
6373
for line in lines:
64-
if (not skipline(line)) and indexing:
65-
content += line + "\n"
74+
if (not skipline(line)) and indexing:
75+
content += clean_line(line) + "\n"
6676
if "<!--start-indexing-for-search-->" in line:
6777
indexing = True
6878
if "<!--stop-indexing-for-search-->" in line:

0 commit comments

Comments
 (0)