Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 666948 | Differences between
and this patch

Collapse All | Expand All

(-)a/netwerk/base/rust-helper/src/lib.rs (-6 / +4 lines)
Lines 1-10 Link Here
1
use std::ascii::AsciiExt;
2
3
extern crate nserror;
1
extern crate nserror;
4
use self::nserror::*;
2
use self::nserror::*;
5
3
6
extern crate nsstring;
4
extern crate nsstring;
7
use self::nsstring::nsACString;
5
use self::nsstring::nsACString;
8
6
9
/// HTTP leading whitespace, defined in netwerk/protocol/http/nsHttp.h
7
/// HTTP leading whitespace, defined in netwerk/protocol/http/nsHttp.h
10
static HTTP_LWS: &'static [u8] = &[' ' as u8, '\t' as u8];
8
static HTTP_LWS: &'static [u8] = &[' ' as u8, '\t' as u8];
Lines 108-143 pub extern "C" fn rust_prepare_accept_la Link Here
108
/// > At all times, language tags and their subtags, including private
106
/// > At all times, language tags and their subtags, including private
109
/// > use and extensions, are to be treated as case insensitive: there
107
/// > use and extensions, are to be treated as case insensitive: there
110
/// > exist conventions for the capitalization of some of the subtags,
108
/// > exist conventions for the capitalization of some of the subtags,
111
/// > but these MUST NOT be taken to carry meaning.
109
/// > but these MUST NOT be taken to carry meaning.
112
///
110
///
113
/// So why is this code even here? See bug 1108183, I guess.
111
/// So why is this code even here? See bug 1108183, I guess.
114
fn canonicalize_language_tag(token: &mut [u8]) {
112
fn canonicalize_language_tag(token: &mut [u8]) {
115
    for c in token.iter_mut() {
113
    for c in token.iter_mut() {
116
        *c = AsciiExt::to_ascii_lowercase(c);
114
        *c = c.to_ascii_lowercase();
117
    }
115
    }
118
116
119
    let sub_tags = token.split_mut(|c| *c == ('-' as u8));
117
    let sub_tags = token.split_mut(|c| *c == ('-' as u8));
120
    for (i, sub_tag) in sub_tags.enumerate() {
118
    for (i, sub_tag) in sub_tags.enumerate() {
121
        if i == 0 {
119
        if i == 0 {
122
            // ISO 639-1 language code, like the "en" in "en-US"
120
            // ISO 639-1 language code, like the "en" in "en-US"
123
            continue;
121
            continue;
124
        }
122
        }
125
123
126
        match sub_tag.len() {
124
        match sub_tag.len() {
127
            // Singleton tag, like "x" or "i". These signify a
125
            // Singleton tag, like "x" or "i". These signify a
128
            // non-standard language, so we stop capitalizing after
126
            // non-standard language, so we stop capitalizing after
129
            // these.
127
            // these.
130
            1 => break,
128
            1 => break,
131
            // ISO 3166-1 Country code, like "US"
129
            // ISO 3166-1 Country code, like "US"
132
            2 => {
130
            2 => {
133
                sub_tag[0] = AsciiExt::to_ascii_uppercase(&sub_tag[0]);
131
                sub_tag[0] = sub_tag[0].to_ascii_uppercase();
134
                sub_tag[1] = AsciiExt::to_ascii_uppercase(&sub_tag[1]);
132
                sub_tag[1] = sub_tag[1].to_ascii_uppercase();
135
            },
133
            },
136
            // ISO 15924 script code, like "Nkoo"
134
            // ISO 15924 script code, like "Nkoo"
137
            4  => {
135
            4  => {
138
                sub_tag[0] = AsciiExt::to_ascii_uppercase(&sub_tag[0]);
136
                sub_tag[0] = sub_tag[0].to_ascii_uppercase();
139
            },
137
            },
140
            _ => {},
138
            _ => {},
141
        };
139
        };
142
    }
140
    }
143
}
141
}

Return to bug 666948