-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Desktop: PDF search text: Remove NULL characters early to avoid possi…
…ble sync issues (#9862)
- Loading branch information
1 parent
8b9ce9e
commit a906e73
Showing
7 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import replaceUnsupportedCharacters from './replaceUnsupportedCharacters'; | ||
|
||
describe('replaceUnsupportedCharacters', () => { | ||
test('should replace NULL characters', () => { | ||
expect(replaceUnsupportedCharacters('Test\x00...')).toBe('Test�...'); | ||
expect(replaceUnsupportedCharacters('\x00Test\x00...')).toBe('�Test�...'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
const replaceUnsupportedCharacters = (text: string) => { | ||
// In the past, NULL characters have caused sync and search issues. | ||
// Because these issues are often difficult to debug, we remove these characters entirely. | ||
// | ||
// See | ||
// - Sync issue: https://github.com/laurent22/joplin/issues/5046 | ||
// - Search issue: https://github.com/laurent22/joplin/issues/9775 | ||
// | ||
// As per the commonmark spec, we replace \x00 with the replacement character. | ||
// (see https://spec.commonmark.org/0.31.2/#insecure-characters). | ||
// | ||
// eslint-disable-next-line no-control-regex | ||
return text.replace(/\x00/g, '\uFFFD'); | ||
}; | ||
|
||
export default replaceUnsupportedCharacters; |