3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-26 05:49:25 +01:00

relax unicode parsing rules

NFKC was previously used for all text. Now, we use NFKC for all args but
the last, which may be free text. This arg is normalized with NFC to
allow for formatting characters.
This commit is contained in:
Jeremy Latt 2014-02-26 13:11:29 -08:00
parent 4df8ec12f6
commit 6f00f89efa
3 changed files with 6 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package irc
import (
"code.google.com/p/go.crypto/bcrypt"
"code.google.com/p/go.text/unicode/norm"
"errors"
"fmt"
"regexp"
@ -99,10 +100,11 @@ var (
func parseLine(line string) (StringCode, []string) {
var parts []string
if colonIndex := strings.IndexRune(line, ':'); colonIndex >= 0 {
lastArg := line[colonIndex+len(":"):]
line = line[:colonIndex-len(" ")]
lastArg := norm.NFC.String(line[colonIndex+len(":"):])
line = norm.NFKC.String(line[:colonIndex-len(" ")])
parts = append(spacesExpr.Split(line, -1), lastArg)
} else {
line = norm.NFKC.String(line)
parts = spacesExpr.Split(line, -1)
}
return StringCode(strings.ToUpper(parts[0])), parts[1:]

View File

@ -23,7 +23,7 @@ var (
)
const (
SEM_VER = "ergonomadic-1.2.5"
SEM_VER = "ergonomadic-1.2.6"
CRLF = "\r\n"
MAX_REPLY_LEN = 512 - len(CRLF)

View File

@ -2,7 +2,6 @@ package irc
import (
"bufio"
"code.google.com/p/go.text/unicode/norm"
"io"
"log"
"net"
@ -24,7 +23,7 @@ type Socket struct {
func NewSocket(conn net.Conn, commands chan<- editableCommand) *Socket {
socket := &Socket{
conn: conn,
reader: bufio.NewReader(norm.NFKC.Reader(conn)),
reader: bufio.NewReader(conn),
writer: bufio.NewWriter(conn),
}