about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-12-22 21:56:36 +0000
committerEric Wong <e@80x24.org>2016-04-05 18:58:27 +0000
commit3e79993321bd0e5a12b104730638eb87947ec86b (patch)
treec12762abe05e9b1ff88dd865f2d282d394ea66c3 /lib/PublicInbox
parent54c10e3aac3020b83a3be0b9578894154bd3de6a (diff)
downloadpublic-inbox-3e79993321bd0e5a12b104730638eb87947ec86b.tar.gz
We need to parse diffs with all manner of funky file names :<
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/RepoBrowseGit.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/PublicInbox/RepoBrowseGit.pm b/lib/PublicInbox/RepoBrowseGit.pm
new file mode 100644
index 00000000..73a236d3
--- /dev/null
+++ b/lib/PublicInbox/RepoBrowseGit.pm
@@ -0,0 +1,29 @@
+# Copyright (C) 2015 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ (https://www.gnu.org/licenses/agpl-3.0.txt)
+
+package PublicInbox::RepoBrowseGit;
+use strict;
+use warnings;
+use base qw(Exporter);
+our @EXPORT_OK = qw(git_unquote);
+
+my %GIT_ESC = (
+        a => "\a",
+        b => "\b",
+        f => "\f",
+        n => "\n",
+        r => "\r",
+        t => "\t",
+        v => "\013",
+);
+
+sub git_unquote {
+        my ($s) = @_;
+        return $s unless ($s =~ /\A"(.*)"\z/);
+        $s = $1;
+        $s =~ s/\\([abfnrtv])/$GIT_ESC{$1}/g;
+        $s =~ s/\\([0-7]{1,3})/chr(oct($1))/ge;
+        $s;
+}
+
+1;