From b324be8cd45dfb8ca1d47950b762b7294aa591c0 Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Sun, 17 Oct 2010 00:02:04 +0200
Subject: [PATCH] unit-name: Fix unescaping

Invalid characters in unit names are escaped as \xFF. However, when
unescaping we were looking for \FF.
---
 src/unit-name.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/unit-name.c b/src/unit-name.c
index dbaa4a7..a5bcf84 100644
--- a/src/unit-name.c
+++ b/src/unit-name.c
@@ -272,13 +272,13 @@ char *unit_name_unescape(const char *f) {
                 else if (*f == '\\') {
                         int a, b;
 
-                        if ((a = unhexchar(f[1])) < 0 ||
-                            (b = unhexchar(f[2])) < 0) {
-                                /* Invalid escape code, let's take it literal then */
+                        if (f[1] != 'x' || (a = unhexchar(f[2])) < 0 ||
+					(b = unhexchar(f[3])) < 0) {
+				/* Invalid escape code, let's take it literal then */
                                 *(t++) = '\\';
                         } else {
                                 *(t++) = (char) ((a << 4) | b);
-                                f += 2;
+                                f += 3;
                         }
                 } else
                         *(t++) = *f;
-- 
1.7.3.1

