flnews_post_proc 2.0 → 2.04

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9d2ff5d6f33555a5059614972dcd6f01920b1a7274662509154e7092db9ca22
4
- data.tar.gz: 9a75540a2daf3b02cd91d2a11f8087a8ddeabc1ccea42be76af23127e0bd9d06
3
+ metadata.gz: f0e31bc94142a2ec47e03c78802b468055b2728fa4d74fa320fcfb5d007ce98a
4
+ data.tar.gz: 8a877289ebfe3c40cc3cf1f02046c667ceec6ba722a7181493d8be819f75af31
5
5
  SHA512:
6
- metadata.gz: 78e67d90fbacd419f0b7d543bb4ea66ea6c06440b6eff215159462f725eef8eb736db604587aa1980929c1f9a65b64fd37ded814735398a84784125acc700da4
7
- data.tar.gz: 45cec798380b42fd1b795a90c3dfd712a9b5f09da94ef592eb0123f9ec615204849781454ca50c386319edbbe280dab10a613e5c358fe2fb605891400a8c5163
6
+ metadata.gz: 224cb017bcd798025b4d159536fce5753a58442d27fde12caad6c7d710330bac1a58fd17c2128310144795143b3ad238582cecdc451baa0c94aa242ff9a067e1
7
+ data.tar.gz: 2d3d88a9bec625acaea47d547d28fc7084a7c56259255e50d312d44808d28d3306e111eed8b9bbea97721cccbe85612de56d970f96f9e6177c650f36a3df8c4b
data/bin/flnews_post_proc CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  =begin
5
5
  /***************************************************************************
6
- * ©2023-2024, Michael Uplawski <michael.uplawski@uplawski.eu> *
6
+ * ©2023-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
7
7
  * *
8
8
  * This program is free software; you can redistribute it and/or modify *
9
9
  * it under the terms of the DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE *
@@ -22,8 +22,7 @@ if ! (/linux/ =~ RUBY_PLATFORM)
22
22
  exit false
23
23
  end
24
24
 
25
- # needs the ruby-filemagic gem
26
- require 'filemagic'
25
+ require 'mimemagic'
27
26
  require 'tempfile'
28
27
 
29
28
  require_relative '../lib/override'
@@ -68,21 +67,24 @@ if (!STDIN.tty?)
68
67
  if !artext.strip.empty?
69
68
  # Be sure to know what you are doing.
70
69
  # Ask around in case of doubt.
71
- mime = FileMagic.mime.buffer artext
72
- debug('mime is ' << mime.split(';')[0])
73
- if (['news', 'rfc822'].none? {|m| mime.start_with?('message/' << m) } )
70
+ type = ''
71
+ magic = MimeMagic.by_magic(artext)
72
+ # mime = FileMagic.mime.buffer artext
73
+ debug('magic is ' << magic.to_s)
74
+ type = magic.type if magic
75
+ if (['news', 'rfc822'].none? {|m| type.start_with?('message/' << m) } )
74
76
  # Not a pure news message
75
77
  # Add more reactions, as you stumble upon them ...
76
- warn ("Input is of wrong mime-type " << mime.split(';')[0])
78
+ warn ("Input is of wrong type " << type)
77
79
 
78
80
  # Javascript okay
79
- if (['javascript'].any? {|m| mime.start_with?('application/' << m)} )
81
+ if (['javascript'].any? {|m| type.start_with?('application/' << m)} )
80
82
  warn 'Input contains java-script code!'
81
83
  # C okay
82
- elsif(['x-c'].any? {|m| mime.start_with?('text/' << m)} )
84
+ elsif(['x-c'].any? {|m| type.start_with?('text/' << m)} )
83
85
  warn 'Input contains C- or C++ code!'
84
86
  # Ruby okay
85
- elsif(['x-ruby'].any? {|m| mime.start_with?('text/' << m) })
87
+ elsif(['x-ruby'].any? {|m| type.start_with?('text/' << m) })
86
88
  warn 'Input contains Ruby-code!'
87
89
  else
88
90
  warn 'Input contains other things than plain-text, but I cannot say, what.'
@@ -98,16 +100,31 @@ if (!STDIN.tty?)
98
100
  # if not disabled (default is true)
99
101
  if config.OVERRIDE_CONFIG != false
100
102
  cdlg = OverrideDlg.new
101
- discarded = cdlg.show
102
- if discarded && !discarded.empty?
103
+ dlg_result = cdlg.show
104
+ discarded = ''
105
+ enabled = ''
106
+ discarded = dlg_result[0]
107
+ enabled = dlg_result[1]
108
+ if discarded && discarded.respond_to?(:to_str) && !discarded.empty?
103
109
  debug('options overriden ' << discarded)
104
110
  OverrideDlg.cvars.each do |v|
105
- if discarded.include?(v.to_s)
106
- debug('removing ' << v.to_s)
111
+ vstr = v.to_s.strip
112
+ if discarded.include?(vstr)
107
113
  config.set(v, nil)
114
+ if v == :DEBUG_LOG
115
+ info 'will stop logging now!'
116
+ clear_log
117
+ set_target nil
118
+ end
108
119
  end
109
120
  end
110
121
  end
122
+ if enabled && enabled.respond_to?(:to_str) && !enabled.empty?
123
+ debug('additional options: ' << enabled)
124
+ enabled.split do |opt|
125
+ config.set(opt.to_sym, true)
126
+ end
127
+ end
111
128
  debug('new config: ' << config.inspect)
112
129
  end
113
130
  #<--------------
@@ -116,9 +133,58 @@ if (!STDIN.tty?)
116
133
  # and get a result.
117
134
  article = pp.article
118
135
  if article
119
- # -------------> The main objective <------
120
- puts article
121
- # <------------- over and out ------>
136
+ if config.DRAFT_ONLY
137
+ draft_dir = config.DRAFT_DIR
138
+ if !draft_dir || draft_dir.empty?
139
+ draft_dir = ENV['TEMP']
140
+ warn 'Will write a draft to the temporary directory ' << draft_dir
141
+ end
142
+ if draft_dir
143
+ draft_dir = File.expand_path(draft_dir)
144
+ debug 'article is a draft, writing to ' << draft_dir
145
+ draft_dir << File::Separator if !draft_dir.strip.end_with?(File::Separator)
146
+ mode = 'w+'
147
+ begin
148
+ Dir.mkdir(draft_dir) if !File::exist?(draft_dir)
149
+ ext = '.draft'
150
+ nbr = 1
151
+ if File.exist?(draft_dir) && File.directory?(draft_dir)
152
+ nbr = Dir::children(draft_dir).collect do |dc|
153
+ debug ' found file ' << dc
154
+ File::file?(dc) && dc.strip.end_with?(ext)
155
+ end.length + 1
156
+
157
+ groups = pp.newsgroups.groups
158
+ fname = draft_dir + nbr.to_s << '_' << groups[0]
159
+ fname << '++' if groups.length > 1
160
+ fname << ext
161
+ debug 'Draft will be ' << fname
162
+ debug 'newsgroups are ' << pp.newsgroups.groups.to_s
163
+ text = pp.newsgroups.groups.join(", ") << $LN << $LN << pp.body.join
164
+ File::write(fname, text)
165
+ info 'Draft written alright' if File::exist?(fname)
166
+ else
167
+ fatal 'draft_dir does not exist and could not be created'
168
+ exit false
169
+ end
170
+ rescue Exception => ex
171
+ fatal "Cannot write draft (" << ex.message << ")"
172
+ exit false
173
+ end
174
+ # Post-Processing ends here ...
175
+ else
176
+ fatal "ABORTING: Directory for draft messages is not set!\nSee configuration, option DRAFT_DIR."
177
+ info "Nothing saved, nothing posted!"
178
+ # ... or here
179
+ exit false
180
+ end
181
+ else
182
+ debug 'writing article to STDOUT'
183
+ # -------------> The main objective <------
184
+ puts article
185
+ # ... or here
186
+ # <------------- over and out ------>
187
+ end
122
188
  exit true
123
189
  end
124
190
  # whatever.
data/changes.txt ADDED
@@ -0,0 +1,46 @@
1
+ v.2.04
2
+ *) Gemspec: Dependencies added
3
+ -) gem New_rfc_2047 was missing from the specs.
4
+ -) MimeMagic was already in the specs
5
+
6
+ v.2.03
7
+ *) Ruby-Filemagic has been replaced by MimeMagic.
8
+ *) Calls to force_encoding() prior String.gsub have been added
9
+ Ruby 4.1.0 appears to be stricter in handling encoding mismatches.
10
+ *) Bugfix: A typo in a require statement had been corrected.
11
+ *) Whiptail dialog code removed
12
+
13
+ v.2.02
14
+ *) Bugfix: There was output to STDOUT unrelated to the message in
15
+ preparation which made Flnews complain. Also, posting was impossible.
16
+ v.2.01
17
+ *) The documentation has been updated.
18
+ *) Corrected behavior when logging is disabled in the interactive dialog
19
+ (pure text only, see next).
20
+ *) Whiptail dialog disabled.
21
+ The “Override-dialog” must be extended to honor new options. Whiptail is
22
+ too mind bending for me. The code is still there, but will probably
23
+ disappear in future program versions.
24
+ *) Draft messages.
25
+ - New configuration option DRAFT_DIR defaults to $TEMP from the
26
+ current environment.
27
+ - Override-dialog as pure text shows new option DRAFT_ONLY.
28
+ When explicitly activated, nothing is posted, but the message stored
29
+ in the DRAFT_DIR (see documentation for more).
30
+ *) This file renamed 'changes.txt'
31
+ *) Pure text dialog to override settings corrected:
32
+ - Option "No Archive" is toggled correctly
33
+ - Unbuffered input from STDIN simplified
34
+ v.2.0
35
+ *) Supersedes will have a new signature by default
36
+ *) Obsolete code for Yad and Zenity dialogs removed.
37
+ v 1.99
38
+ *) Bugfix: The value of a custom header can include a colon.
39
+ Example: x-my-header: apples: 2,90, peers: 3,10
40
+ (before, the value would have been clipped after the first ':')
41
+ v 1.98
42
+ *) New change log (this file)
43
+ *) In the configuration file, log levels can be in upper case.
44
+ v 1.97
45
+ *) Custom headers are RFC 2047 encoded, if need be.
46
+ (before, they had to be ASCII only or were discarded).
@@ -266,17 +266,22 @@
266
266
  <h3>Dialog for Overriding Settings</h3>
267
267
 
268
268
  <blockquote>
269
- <p><strong>IMPORTANT</strong>: As of version 1.72, YAD or
270
- Zenity cannot be used for the dialog interface.</p>
269
+ <p><strong>IMPORTANT</strong>: As of version 2.01, only
270
+ the text interface remains to display the dialog.
271
+ <a class="reference external" href=
272
+ "https://xterm.dev/">XTerm</a> must be installed to use
273
+ the dialog.</p>
271
274
 
272
275
  <p>Before the post-processor runs, a dialog can be
273
276
  displayed to allow users to <strong>disable</strong>
274
277
  certain <a class="reference internal" href=
275
- "#configuration">CONFIGURATION</a> options. If Whiptail
276
- or xterm are available, you can choose to disable the
278
+ "#configuration">CONFIGURATION</a> options and – as of
279
+ version 2.01 to <strong>enable</strong> others . If
280
+ XTerm is available, you can choose to disable the
277
281
  following options. You <strong>cannot</strong> enable
278
282
  options that haven't already been set in the
279
- configuration.</p>
283
+ configuration. But you can choose to add an option that
284
+ is not present in the configuration file:</p>
280
285
 
281
286
  <blockquote>
282
287
  <ul class="simple">
@@ -306,6 +311,27 @@
306
311
  </ul>
307
312
  </blockquote>
308
313
 
314
+ <p>There is 1 additional option, which is disabled by
315
+ default, that you can enable only in the dialog and
316
+ nowhere else:</p>
317
+
318
+ <blockquote>
319
+ <ul class="simple">
320
+ <li>
321
+ <p>The current message can be saved as a draft,
322
+ <strong>instead</strong> of being posted to
323
+ Usenet.</p>
324
+ </li>
325
+ </ul>
326
+ </blockquote>
327
+
328
+ <p>When your configuration contains the path to a
329
+ directory for these drafts (option <a class=
330
+ "reference internal" href="#draft-dir">DRAFT_DIR</a>), it
331
+ will be used to store these draft messages, otherwise the
332
+ temporary directory from the environment variable
333
+ $TEMP.</p>
334
+
309
335
  <p>Pressing Esc or the Cancel button on the dialog will
310
336
  interrupt the process, and flnews will not post the
311
337
  article.</p>
@@ -584,6 +610,37 @@ comp.*: /home/[user]/.my_sigs</pre>
584
610
 
585
611
  <p>EXAMPLE: yes</p>
586
612
  </blockquote>
613
+
614
+ <p id="draft-dir"><strong>DRAFT_DIR</strong>
615
+ </p>
616
+
617
+ <blockquote>
618
+ <p>The path to a directory for draft messages. You can
619
+ activate an option DRAFT_ONLY in the <a class=
620
+ "reference internal" href=
621
+ "#dialog-for-overriding-settings">Dialog for Overriding
622
+ Settings</a>. The current message will then be saved to
623
+ this directory, <strong>instead</strong> of being posted
624
+ to Usenet. If you leave this option empty, a temporary
625
+ directory ($TEMP) will be used instead. The draft files
626
+ will be named according to this schema:</p>
627
+
628
+ <blockquote>
629
+ <p>[n][1st_group][++].draft</p>
630
+ </blockquote>
631
+
632
+ <p>where <em>n</em> is the number of files in this
633
+ directory, <em>1st_group</em> the first newsgroup that
634
+ the message was addressed to and <em>++</em> an optional
635
+ suffix, indicating that there are more newsgroups in the
636
+ list (cross post). The content of a draft file is the
637
+ current body of the message, preceded by the list of
638
+ newsgroups.</p>
639
+
640
+ <p>DEFAULT: empty</p>
641
+
642
+ <p>EXAMPLE: ~/.flnews_drafts</p>
643
+ </blockquote>
587
644
  </section>
588
645
  </section>
589
646
 
@@ -657,43 +714,10 @@ comp.*: /home/[user]/.my_sigs</pre>
657
714
  <span id="signatures-in-supersedes"></span>
658
715
  <h3>Signatures in Supersedes</h3>
659
716
 
660
- <blockquote>
661
- <p>When superseding an existing post, the post-processor
662
- will NOT automatically add a signature. This preserves
663
- the original post content as much as possible.</p>
664
-
665
- <p>To retain the signature from the original post:</p>
666
-
667
- <ol class="arabic simple">
668
- <li>
669
- <p>In flnews, select the entire article body with the
670
- mouse—from the first line (including any
671
- introductions) down to the last line of the
672
- signature.</p>
673
- </li>
674
-
675
- <li>
676
- <p>From the Article menu, select
677
- <strong>Supersede</strong>.</p>
678
- </li>
679
-
680
- <li>
681
- <p>Edit the article text as needed. The signature
682
- will be included in te editable text (normally,
683
- flnews strips signatures before opening the
684
- editor).</p>
685
- </li>
686
-
687
- <li>
688
- <p>Send the article.</p>
689
- </li>
690
- </ol>
691
-
692
- <p><strong>Note:</strong> The <a class=
693
- "reference internal" href="#override-dialog">override
694
- dialog</a> (see above) does not affect signatures in
695
- superseding posts.</p>
696
- </blockquote>
717
+ <p>Since version 2.0, signatures in supersedes are not
718
+ handled differently from other articles. This paragraph
719
+ will be removed in the next version of the
720
+ documentation.</p>
697
721
  </section>
698
722
 
699
723
  <section id="testing-1">
@@ -711,13 +735,13 @@ comp.*: /home/[user]/.my_sigs</pre>
711
735
  <p><strong>:~$ /usr/local/bin/[post-processor] &lt;
712
736
  [test-article]</strong>
713
737
  </p>
714
- </li>
715
- </ol>
716
738
 
717
- <p>This will show the modified article, and you can pipe
718
- it into another file for further testing.</p>
739
+ <blockquote>
740
+ <p>This will show the modified article, and you can
741
+ pipe it into another file for further testing.</p>
742
+ </blockquote>
743
+ </li>
719
744
 
720
- <ol class="arabic simple" start="2">
721
745
  <li>
722
746
  <p>Post directly to a test newsgroup (e.g.,
723
747
  alt.test). This is essential before posting to real
@@ -801,7 +825,7 @@ comp.*: /home/[user]/.my_sigs</pre>
801
825
  "https://creativecommons.org/licenses/by-nd/4.0/">CC
802
826
  BY-ND 4.0</a></p>
803
827
 
804
- <p>Date: 2026-07-16</p>
828
+ <p>Date: 2026-08-01</p>
805
829
  </blockquote>
806
830
 
807
831
  <p><strong>Ω</strong>
@@ -811,7 +835,7 @@ comp.*: /home/[user]/.my_sigs</pre>
811
835
  </main>
812
836
 
813
837
  <div id='page_dt'>
814
- 2026-07-16
838
+ 2026-08-01
815
839
  </div>
816
840
  </body>
817
841
  </html>
Binary file
Binary file
@@ -10,6 +10,7 @@ flnews_post_proc
10
10
  .. _CC By-ND 4.0: https://creativecommons.org/licenses/by-nd/4.0/
11
11
  .. _rubygems.org: https://rubygems.org/gems/flnews_post_proc
12
12
  .. _en Français: https://www.uplawski.eu/div/flnews/gem_doc/fr
13
+ .. _XTerm: https://xterm.dev/
13
14
 
14
15
 
15
16
  ------------------------------------------
@@ -100,13 +101,15 @@ Limitations of Basic Newsreaders
100
101
 
101
102
  Dialog for Overriding Settings
102
103
  ------------------------------
103
- **IMPORTANT**: As of version 1.72, YAD or Zenity cannot be used for the dialog
104
- interface.
104
+ **IMPORTANT**: As of version 2.01, only the text interface remains to display the dialog.
105
+ `XTerm`_ must be installed to use the dialog.
105
106
 
106
107
  Before the post-processor runs, a dialog can be displayed to allow users to
107
- **disable** certain `CONFIGURATION`_ options. If Whiptail or xterm are available,
108
- you can choose to disable the following options. You **cannot** enable options
109
- that haven't already been set in the configuration.
108
+ **disable** certain `CONFIGURATION`_ options and as of version 2.01 – to
109
+ **enable** others . If XTerm is available, you can choose to disable the
110
+ following options. You **cannot** enable options that haven't already been
111
+ set in the configuration. But you can choose to add an option that is not present
112
+ in the configuration file:
110
113
 
111
114
  * Signatures (if set in the `CONFIGURATION`_) can be **ignored**. A default signature will be used, or no signature at all.
112
115
 
@@ -116,6 +119,13 @@ Dialog for Overriding Settings
116
119
 
117
120
  * Logging can be **disabled**, if enabled.
118
121
 
122
+ There is 1 additional option, which is disabled by default, that you can enable only in the dialog and nowhere else:
123
+
124
+ * The current message can be saved as a draft, **instead** of being posted to Usenet.
125
+
126
+ When your configuration contains the path to a directory for these drafts (option `DRAFT_DIR`_), it will be used to store
127
+ these draft messages, otherwise the temporary directory from the environment variable $TEMP.
128
+
119
129
  Pressing Esc or the Cancel button on the dialog will interrupt the process, and
120
130
  flnews will not post the article.
121
131
 
@@ -325,6 +335,28 @@ Configuration Options
325
335
 
326
336
  EXAMPLE: yes
327
337
 
338
+ .. _DRAFT_DIR:
339
+
340
+ **DRAFT_DIR**
341
+
342
+ The path to a directory for draft messages. You can activate an option
343
+ DRAFT_ONLY in the `Dialog for Overriding Settings`_. The current message will
344
+ then be saved to this directory, **instead** of being posted to Usenet.
345
+ If you leave this option empty, a temporary directory ($TEMP) will be used instead.
346
+ The draft files will be named according to this schema:
347
+
348
+ [n][1st_group][++].draft
349
+
350
+ where *n* is the number of files in this directory, *1st_group* the first
351
+ newsgroup that the message was addressed to and *++* an optional suffix,
352
+ indicating that there are more newsgroups in the list (cross post). The
353
+ content of a draft file is the current body of the message, preceded by the
354
+ list of newsgroups.
355
+
356
+ DEFAULT: empty
357
+
358
+ EXAMPLE: ~/.flnews_drafts
359
+
328
360
  .. _Other Information:
329
361
 
330
362
  Other Information
@@ -377,20 +409,9 @@ Editing footnotes
377
409
 
378
410
  Signatures in Supersedes
379
411
  ------------------------
380
- When superseding an existing post, the post-processor will NOT automatically add a signature.
381
- This preserves the original post content as much as possible.
382
-
383
- To retain the signature from the original post:
384
-
385
- 1. In flnews, select the entire article body with the mouse—from the first line (including any introductions) down to the last line of the signature.
386
-
387
- 2. From the Article menu, select **Supersede**.
388
-
389
- 3. Edit the article text as needed. The signature will be included in te editable text (normally, flnews strips signatures before opening the editor).
390
-
391
- 4. Send the article.
392
-
393
- **Note:** The `override dialog`_ (see above) does not affect signatures in superseding posts.
412
+ Since version 2.0, signatures in supersedes are not handled differently from
413
+ other articles. This paragraph will be removed in the next version of the
414
+ documentation.
394
415
 
395
416
  .. _Testing:
396
417
 
@@ -402,8 +423,8 @@ Testing
402
423
 
403
424
  **:~$ /usr/local/bin/[post-processor] < [test-article]**
404
425
 
405
- This will show the modified article, and you can pipe it into another file
406
- for further testing.
426
+ This will show the modified article, and you can pipe it into another file
427
+ for further testing.
407
428
 
408
429
  2. Post directly to a test newsgroup (e.g., alt.test). This is essential before posting to real newsgroups,
409
430
  especially when the post-processor will alter the article.
data/lib/basic_logging.rb CHANGED
@@ -60,18 +60,19 @@ module BasicLogging
60
60
  msg = calling_method << ": ERROR : invalid log level \"" << lv.to_s << "\""
61
61
  msg << "\n" << "Keepinng old log level " << Levels.keys.detect {| k| Levels[k] == @@log_level}.to_s
62
62
  STDERR.puts msg
63
- puts msg
63
+ # puts msg
64
64
  end
65
65
  end
66
66
 
67
67
  # set the log target
68
68
  def set_target(tg)
69
- if tg.respond_to?(:to_io)
69
+ # STDOUT.puts 'BASICLOGGING : Setting target to ' << tg.to_s
70
+ if tg && tg.respond_to?(:to_io)
70
71
  @@target = tg
71
- elsif(!File::exist?(tg) || ( File.file?(tg) && File.writable?(tg) ) )
72
- @@target = File.open(tg, 'w+')
73
72
  elsif !tg || tg.respond_to?(:to_str) && tg.strip.empty?
74
73
  @@target = nil
74
+ elsif(!File::exist?(tg) || ( File.file?(tg) && File.writable?(tg) ) )
75
+ @@target = File.open(tg, 'w+')
75
76
  else
76
77
  STDERR.puts calling_method << ': ERROR : target ' << tg.to_str << ' cannot be set'
77
78
  STDERR.puts "Keeping old target " << @@target.inspect
data/lib/body.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  =begin
4
4
  /***************************************************************************
5
- * 2023-2025, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * 2023-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
6
6
  * This program is free software; you can redistribute it and/or modify *
7
7
  * it under the terms of the WTFPL 2.0 or later, see *
8
8
  * http://www.wtfpl.net/about/ *
@@ -167,7 +167,8 @@ class Body
167
167
  end
168
168
 
169
169
  def join
170
- new_body = @lines.join("\r\n") << "\r\n"
170
+ lines = @lines.collect{|l| l.force_encoding('utf-8')}
171
+ new_body = lines.join("\r\n") << "\r\n"
171
172
  # replace ellipsis
172
173
  new_body.gsub!('...', '…')
173
174
  return new_body
@@ -187,21 +188,11 @@ class Body
187
188
  if @@config.VFY_URLS
188
189
  debug 'verifying URLs'
189
190
  @lines.each_with_index do | l, i |
190
- # leave cited lines as they are.
191
+ # leave quoted lines as they are.
191
192
  if !l.start_with?( '>')
192
- =begin Currently Unused
193
- # IMPORTANT --------------------------------->
194
- # IT IS HENCEFORTH PROHIBITED TO WRITE AN EMAIL-ADDRESS
195
- # IN THE BODY OF A NEWS-POST AND TO NOT PREPEND IT WITH
196
- # mailto:
197
- # ... Because I do not know what to do in these cases,
198
- # and I am the boss!
199
- # <----------------------------
200
-
201
- # BUGFIX : Urls with @
202
- # BUGFIX : email address in the intro
203
- new_line = handle_news(l) if !@intro || l.strip != @intro.strip
204
- =end
193
+ # Handling of news- and mail-links has been
194
+ # removed.
195
+ #
205
196
  # http(s)
206
197
  if l.include?('http')
207
198
  new_line = handle_http(l)
@@ -218,7 +209,8 @@ class Body
218
209
  ref_delim = @@config.REFERENCES_DELIMITER
219
210
  debug('references delimiter is ' << ref_delim)
220
211
  references = Array.new
221
- body = @lines.join($LN)
212
+ # avoids a lot of trouble
213
+ body = @lines.join($LN).force_encoding('utf-8')
222
214
  if ref_delim && !ref_delim.strip.empty?
223
215
  unless ref_delim == ref_delim.reverse
224
216
  ref_delim.strip!
@@ -276,34 +268,6 @@ class Body
276
268
  end
277
269
  private
278
270
 
279
- # handle <news:..@...>
280
- def handle_news(l)
281
- # ... “Do not trust nobody!”
282
- if l.include?('@') && ! l.include?('http:') && ! l.include?('https:')
283
- # And I forgot how this works. It does.
284
- l.split.collect do |ele|
285
- # angular brackets are there alright. Hurra.
286
- url = ele.match(/\<(.*)\>/)
287
- unless !url
288
- debug(' with angular brackets: ' << url.inspect)
289
- l = l.sub(url[1], 'news:' << url[1]) if !url[1].start_with?('mailto') && !url[1].start_with?('news')
290
- else
291
- url = ele.match(/\S+@(\.|[^\p{P}]+)\S+/)
292
- if url
293
- debug(' withOUT angular brackets: ' << url.inspect)
294
- if !url[0].start_with?('mailto') && !url[0].start_with?('news')
295
- l.sub!(url[0], 'news:' << url[0] )
296
- end
297
- l.sub!('news:', '<news:')
298
- l.sub!(url[0], url[0] << '>')
299
- end
300
- end
301
- end # url_strs = collect
302
- debug(' news: line is now ' << l)
303
- return l
304
- end
305
- end
306
-
307
271
  # formatting http URLs, not much is done here.
308
272
  def handle_http(l)
309
273
  debug('handle http')
data/lib/color_output.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #encoding: UTF-8
2
2
  =begin
3
- /***************************************************************************
4
- * 2023-2024, Michael Uplawski <michael.uplawski@uplawski.eu> *
3
+ ***************************************************************************
4
+ * 2023-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
5
  * This program is free software; you can redistribute it and/or modify *
6
6
  * it under the terms of the WTFPL 2.0 or later, see *
7
7
  * http://www.wtfpl.net/about/ *
@@ -10,7 +10,7 @@
10
10
  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
11
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
12
12
  * *
13
- ***************************************************************************/
13
+ ***************************************************************************
14
14
  =end
15
15
 
16
16
  # Functions to apply colors to terminal output.