From d30dd44c1a5eeac330a4281e58db9a0873b32271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=A4nzer?= Date: Tue, 31 Jan 2012 03:30:29 +0100 Subject: bug 1011: Escape all special characters, not only non-ASCII ones while keeping the PO file intact MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Tänzer --- locale/Makefile | 3 +- locale/escape_special_chars.php | 65 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100755 locale/escape_special_chars.php diff --git a/locale/Makefile b/locale/Makefile index b703fb2..1517066 100644 --- a/locale/Makefile +++ b/locale/Makefile @@ -112,8 +112,7 @@ $(LANGS:%=$(MO_FILE_TEMPLATE)): $(MO_FILE_TEMPLATE): $(PO_FILE_TEMPLATE) $(LANGS:%=$(PO_FILE_TEMPLATE)): mkdir -p $(@D) wget --output-document - '$(@:$(PO_FILE_TEMPLATE)=$(PO_URL_TEMPLATE))' | \ - # convert UTF-8 characters to HTML entities \ - php -r 'while (!feof(STDIN)) echo mb_convert_encoding(fgets(STDIN), "HTML-ENTITIES", "UTF-8");' \ + php -f escape_special_chars.php \ > $@ diff --git a/locale/escape_special_chars.php b/locale/escape_special_chars.php new file mode 100755 index 0000000..4ec0d9a --- /dev/null +++ b/locale/escape_special_chars.php @@ -0,0 +1,65 @@ +#!/usr/bin/php -q + Date: Tue, 31 Jan 2012 04:00:35 +0100 Subject: bug 1011: work around PHP 5.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHP 5.2 gives a warning when the first string in substr_compare() is shorter than $length while PHP 5.3 does not care. Of course this change in behaviour is not documented and PHP as we know and love it doesn't report this error on STDERR but spills its crap all over STDIN which causes msgfmt to get all confused Signed-off-by: Michael Tänzer --- locale/escape_special_chars.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/locale/escape_special_chars.php b/locale/escape_special_chars.php index 4ec0d9a..32de390 100755 --- a/locale/escape_special_chars.php +++ b/locale/escape_special_chars.php @@ -20,21 +20,30 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /* Convert special characters in UTF-8 encoded PO files to HTML entities */ +define('MSGSTR', 'msgstr'); +define('MSGSTR_LEN', strlen(MSGSTR)); +define('MSGID', 'msgid'); +define('MSGID_LEN', strlen(MSGID)); function is_msgstr($line) { - return substr_compare($line, 'msgstr', 0, strlen('msgstr')) === 0; + if (strlen($line) < MSGSTR_LEN) { + return false; + } + + return substr_compare($line, MSGSTR, 0, MSGSTR_LEN) === 0; } function is_msgid($line) { - return substr_compare($line, 'msgid', 0, strlen('msgid')) === 0; + if (strlen($line) < MSGID_LEN) { + return false; + } + + return substr_compare($line, MSGID, 0, MSGID_LEN) === 0; } // Skip the metadata (first msgid/msgstr pair) while (!feof(STDIN)) { $line = fgets(STDIN); - if ($line === false) { - exit(0); //EOF after newline mostly - } echo $line; @@ -48,9 +57,6 @@ $msgstr = false; while (!feof(STDIN)) { $line = fgets(STDIN); - if ($line === false) { - exit(0); //EOF after newline mostly - } if (is_msgstr($line)) { $msgstr = true; -- cgit v1.2.1 From 453ad50dc25092fd99fed58147168056580db05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=A4nzer?= Date: Wed, 8 Feb 2012 00:31:06 +0100 Subject: bug 1011: Move HTML markup out of the translation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Tänzer --- pages/account/40.php | 7 ++++++- pages/wot/14.php | 6 +++++- www/advertising.php | 6 +++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pages/account/40.php b/pages/account/40.php index 8391903..6e0e343 100644 --- a/pages/account/40.php +++ b/pages/account/40.php @@ -65,7 +65,12 @@ if(!array_key_exists('secrethash',$_SESSION['_config'])) $_SESSION['_config']['s

-

bugs.cacert.org and mark it as private.")?>

+

support@cacert.org", + "bugs.cacert.org")?>

diff --git a/pages/wot/14.php b/pages/wot/14.php index 21c5873..a827ee4 100644 --- a/pages/wot/14.php +++ b/pages/wot/14.php @@ -20,7 +20,11 @@

","")?>

-

http://www.buergerkarte.at/bku/. To activate your E-Card, please go to https://www.sozialversicherung.at/signon2-Registrierung/."))?>

+

http://www.buergerkarte.at/bku/", + "https://www.sozialversicherung.at/signon2-Registrierung/" + )?>

diff --git a/www/advertising.php b/www/advertising.php index e987461..43e4f93 100644 --- a/www/advertising.php +++ b/www/advertising.php @@ -47,7 +47,7 @@ if($months < 1 || $months > 12) { $id = 1; - $errmsg .= _("You can only place an advertisement for up to 12 months.
"); + $errmsg .= _("You can only place an advertisement for up to 12 months.")."
"; $process=""; $oldid=0; } @@ -55,7 +55,7 @@ if(strlen($title) <= 5) { $id = 1; - $errmsg .= _("Link title was too short.
"); + $errmsg .= _("Link title was too short.")."
"; $process=""; $oldid=0; } @@ -63,7 +63,7 @@ if(strlen($link) <= 10) { $id = 1; - $errmsg .= _("Link URI was too short.
"); + $errmsg .= _("Link URI was too short.")."
"; $process=""; $oldid=0; } -- cgit v1.2.1