2005-03-03 11:03:37

by Martin Waitz

[permalink] [raw]
Subject: [PATCH 15/16] [DocBook] factor out escaping of XML special characters

[DocBook] factor out escaping of XML special characters
Signed-off-by: Martin Waitz <[email protected]>


# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.2039 -> 1.2040
# scripts/kernel-doc 1.26 -> 1.27
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 05/03/03 [email protected] 1.2040
# [DocBook] factor out escaping of XML special characters
#
# Signed-off-by: Martin Waitz <[email protected]>
# --------------------------------------------
#
diff -Nru a/scripts/kernel-doc b/scripts/kernel-doc
--- a/scripts/kernel-doc Thu Mar 3 11:43:21 2005
+++ b/scripts/kernel-doc Thu Mar 3 11:43:21 2005
@@ -1624,6 +1624,15 @@
}
}

+# replace <, >, and &
+sub xml_escape($) {
+ shift;
+ s/\&/\\\\\\amp;/g;
+ s/\</\\\\\\lt;/g;
+ s/\>/\\\\\\gt;/g;
+ return $_;
+}
+
sub process_file($) {
my ($file) = "$ENV{'SRCTREE'}@_";
my $identifier;
@@ -1695,10 +1704,7 @@
$newcontents = $2;

if ($contents ne "") {
- $contents =~ s/\&/\\\\\\amp;/g;
- $contents =~ s/\</\\\\\\lt;/g;
- $contents =~ s/\>/\\\\\\gt;/g;
- dump_section($section, $contents);
+ dump_section($section, xml_escape($contents));
$section = $section_default;
}

@@ -1710,10 +1716,7 @@
} elsif (/$doc_end/) {

if ($contents ne "") {
- $contents =~ s/\&/\\\\\\amp;/g;
- $contents =~ s/\</\\\\\\lt;/g;
- $contents =~ s/\>/\\\\\\gt;/g;
- dump_section($section, $contents);
+ dump_section($section, xml_escape($contents));
$section = $section_default;
$contents = "";
}
@@ -1727,10 +1730,7 @@
# @parameter line to signify start of description
if ($1 eq "" &&
($section =~ m/^@/ || $section eq $section_context)) {
- $contents =~ s/\&/\\\\\\amp;/g;
- $contents =~ s/\</\\\\\\lt;/g;
- $contents =~ s/\>/\\\\\\gt;/g;
- dump_section($section, $contents);
+ dump_section($section, xml_escape($contents));
$section = $section_default;
$contents = "";
} else {


2005-03-06 08:07:44

by Martin Waitz

[permalink] [raw]
Subject: Re: [PATCH 15/16] [DocBook] factor out escaping of XML special characters

hoi :)

well, this patch is broken :(

On Thu, Mar 03, 2005 at 11:43:17AM +0100, Martin Waitz wrote:
> --- a/scripts/kernel-doc Thu Mar 3 11:43:21 2005
> +++ b/scripts/kernel-doc Thu Mar 3 11:43:21 2005
> @@ -1624,6 +1624,15 @@
> }
> }
>
> +# replace <, >, and &
> +sub xml_escape($) {
> + shift;

this must be: $_ = shift;

> + s/\&/\\\\\\amp;/g;
> + s/\</\\\\\\lt;/g;
> + s/\>/\\\\\\gt;/g;
> + return $_;
> +}
> +
> sub process_file($) {
> my ($file) = "$ENV{'SRCTREE'}@_";
> my $identifier;


this is also fixed in my BK repository.
(I'll send mail with other updates to lkml later)

--
Martin Waitz


Attachments:
(No filename) (625.00 B)
signature.asc (189.00 B)
Digital signature
Download all attachments