-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDNA support #119
Merged
Merged
IDNA support #119
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fee35ca
IDNA support
valenting ca0ff3c
Add UTS46 tests
valenting 727220a
IDNA: replace boolean parameters with a struct with named fields
SimonSapin 7bb230f
Use a custom enum rather than strings for IDNA errors
SimonSapin cd24385
Add IDNA mapping table in source form to the repository.
SimonSapin ed30dca
Use char literals in IDNA mapping.
SimonSapin 5a8d271
Refactor IDNA
SimonSapin a6599b9
IDNA: Add DNS length check
SimonSapin c35d040
Implement most validitiy criteria
SimonSapin cb187a9
IDNA: Implement (most) bidi rules.
valenting 9801e28
Change unicode-bidi dependency to version 0.2.3
valenting eb3846d
Use matches! macro and chars.skip(2). Remove unused error code.
valenting File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,60 @@ | ||
# Copyright 2013-2014 Valentin Gosu. | ||
# | ||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
# option. This file may not be copied, modified, or distributed | ||
# except according to those terms. | ||
|
||
|
||
# Run as: python make_idna_table.py idna_table.txt > src/idna_table.rs | ||
# You can get the latest idna table from | ||
# http://www.unicode.org/Public/idna/latest/IdnaMappingTable.txt | ||
|
||
print('''\ | ||
// Copyright 2013-2014 Valentin Gosu. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Generated by make_idna_table.py | ||
|
||
use idna::Mapping::*; | ||
use idna::Range; | ||
|
||
pub static TABLE: &'static [Range] = &[ | ||
''') | ||
|
||
txt = open("IdnaMappingTable.txt") | ||
|
||
def char(s): | ||
return (unichr(int(s, 16)) | ||
.encode('utf8') | ||
.replace('\\', '\\\\') | ||
.replace('"', '\\"') | ||
.replace('\0', '\\0')) | ||
|
||
for line in txt: | ||
# remove comments | ||
line, _, _ = line.partition('#') | ||
# skip empty lines | ||
if len(line.strip()) == 0: | ||
continue | ||
fields = line.split(';') | ||
if fields[0].strip() == 'D800..DFFF': | ||
continue # Surrogates don't occur in Rust strings. | ||
first, _, last = fields[0].strip().partition('..') | ||
if not last: | ||
last = first | ||
mapping = fields[1].strip().replace('_', ' ').title().replace(' ', '') | ||
if len(fields) > 2: | ||
if fields[2].strip(): | ||
mapping += '("%s")' % ''.join(char(c) for c in fields[2].strip().split(' ')) | ||
elif mapping == "Deviation": | ||
mapping += '("")' | ||
print(" Range { from: '%s', to: '%s', mapping: %s }," % (char(first), char(last), mapping)) | ||
|
||
print("];") |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
idna_table.txt
provided by Unicode? Where can it be found?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://www.unicode.org/Public/idna/latest/IdnaMappingTable.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this URL in a code comment.