diff --git a/eeprom/decode-dimms b/eeprom/decode-dimms
index 297e6a7..aa12719 100755
--- a/eeprom/decode-dimms
+++ b/eeprom/decode-dimms
@@ -349,16 +349,21 @@ sub cas_latencies(@)
# Real printing functions
+sub html_encode($)
+{
+ my $text = shift;
+ $text =~ s/\</sg;
+ $text =~ s/>/\>/sg;
+ $text =~ s/\n/
\n/sg;
+ return $text;
+}
+
sub real_printl($$) # print a line w/ label and value
{
my ($label, $value) = @_;
if ($opt_html) {
- $label =~ s/\</sg;
- $label =~ s/>/\>/sg;
- $label =~ s/\n/
\n/sg;
- $value =~ s/\</sg;
- $value =~ s/>/\>/sg;
- $value =~ s/\n/
\n/sg;
+ $label = html_encode($label);
+ $value = html_encode($value);
print "
$label | $value |
\n";
} else {
my @values = split /\n/, $value;
@@ -371,12 +376,8 @@ sub printl2($$) # print a line w/ label and value (outside a table)
{
my ($label, $value) = @_;
if ($opt_html) {
- $label =~ s/\</sg;
- $label =~ s/>/\>/sg;
- $label =~ s/\n/
\n/sg;
- $value =~ s/\</sg;
- $value =~ s/>/\>/sg;
- $value =~ s/\n/
\n/sg;
+ $label = html_encode($label);
+ $value = html_encode($value);
}
print "$label: $value\n";
}
@@ -385,9 +386,7 @@ sub real_prints($) # print separator w/ given text
{
my ($label) = @_;
if ($opt_html) {
- $label =~ s/\</sg;
- $label =~ s/>/\>/sg;
- $label =~ s/\n/
\n/sg;
+ $label = html_encode($label);
print "$label |
\n";
} else {
print "\n---=== $label ===---\n";
@@ -398,12 +397,8 @@ sub printh($$) # print header w/ given text
{
my ($header, $sub) = @_;
if ($opt_html) {
- $header =~ s/\</sg;
- $header =~ s/>/\>/sg;
- $header =~ s/\n/
\n/sg;
- $sub =~ s/\</sg;
- $sub =~ s/>/\>/sg;
- $sub =~ s/\n/
\n/sg;
+ $header = html_encode($header);
+ $sub = html_encode($sub);
print "$header
\n";
print "$sub
\n";
} else {
@@ -415,9 +410,7 @@ sub printc($) # print comment
{
my ($comment) = @_;
if ($opt_html) {
- $comment =~ s/\</sg;
- $comment =~ s/>/\>/sg;
- $comment =~ s/\n/
\n/sg;
+ $comment = html_encode($comment);
print "\n";
} else {
print "# $comment\n";