From 86f243a421728ab2731ae19fc3c5dad5846eff85 Mon Sep 17 00:00:00 2001 From: Seth MacPherson Date: Thu, 31 Jan 2013 12:29:48 -0800 Subject: [PATCH] Corrected multibyte character encoding issue by explicitly setting the page encoding and updating /regexp/ with Regexp.new/escape etc. --- lib/vcard/bnf.rb | 7 +++++-- lib/vcard/version.rb | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/vcard/bnf.rb b/lib/vcard/bnf.rb index 580973e..b5abe52 100644 --- a/lib/vcard/bnf.rb +++ b/lib/vcard/bnf.rb @@ -1,3 +1,4 @@ +# encoding: ascii # Copyright (C) 2008 Sam Roberts # This library is free software; you can redistribute it and/or modify @@ -59,12 +60,14 @@ module Bnf #:nodoc: # QSAFE-CHAR = WSP / %x21 / %x23-7E / NON-US-ASCII # ; Any character except CTLs and DQUOTE - QSAFECHAR = /[ \t\x21\x23-\x7e\x80-\xff]/ + # set ascii encoding so that multibyte chars can be properly escaped + QSAFECHAR = Regexp.new("[ \t\x21\x23-\x7e\x80-\xff]") ALL_QSAFECHARS = /\A#{QSAFECHAR}*\z/ # SAFE-CHAR = WSP / %x21 / %x23-2B / %x2D-39 / %x3C-7E / NON-US-ASCII # ; Any character except CTLs, DQUOTE, ";", ":", "," - SAFECHAR = /[ \t\x21\x23-\x2b\x2d-\x39\x3c-\x7e\x80-\xff]/ + # escape character classes then create new Regexp + SAFECHAR = Regexp.new(Regexp.escape("[ \t\x21\x23-\x2b\x2d-\x39\x3c-\x7e\x80-\xff]")) ALL_SAFECHARS = /\A#{SAFECHAR}*\z/ end end diff --git a/lib/vcard/version.rb b/lib/vcard/version.rb index fc9a9ea..4c9d0d6 100644 --- a/lib/vcard/version.rb +++ b/lib/vcard/version.rb @@ -1,3 +1,3 @@ module Vcard - VERSION = "0.2.2" + VERSION = "0.2.3" end