Bug 8609 - Add an URL validation plugin for authority and biblio frameworks
Summary: Add an URL validation plugin for authority and biblio frameworks
Status: CLOSED WONTFIX
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Maxime Beaulieu
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-09 17:14 UTC by Frédérick Capovilla
Modified: 2023-12-28 20:42 UTC (History)
13 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Add an URL validation plugin for authority and biblio frameworks. (6.56 KB, patch)
2012-08-09 17:14 UTC, Frédérick Capovilla
Details | Diff | Splinter Review
New version of the patch, rebase on master and using Common::Regex::URI. (6.73 KB, patch)
2014-03-19 18:18 UTC, Frédérick Capovilla
Details | Diff | Splinter Review
Add an URL validation plugin for authority and biblio frameworks. (6.76 KB, patch)
2014-08-29 13:41 UTC, simith.doliveira
Details | Diff | Splinter Review
Bug 8609 - Add an URL validation plugin for authority and biblio frameworks (8.31 KB, patch)
2014-08-29 13:49 UTC, simith.doliveira
Details | Diff | Splinter Review
Bug 8609 - Add an URL validation plugin for authority and biblio frameworks (8.31 KB, patch)
2015-05-08 02:23 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 8609 - Add an URL validation plugin for authority and biblio frameworks (8.53 KB, patch)
2015-07-30 12:42 UTC, Rémi Mayrand-Provencher
Details | Diff | Splinter Review
Bug8609 - Removed useless plugin_parameters sub (855 bytes, patch)
2015-07-30 13:10 UTC, Rémi Mayrand-Provencher
Details | Diff | Splinter Review
Bug 8609 - Add an URL validation plugin for authority and biblio frameworks (8.48 KB, patch)
2016-02-15 20:53 UTC, Rémi Mayrand-Provencher
Details | Diff | Splinter Review
Bug 8609 - Add an URL validation plugin for authority and biblio frameworks (8.42 KB, patch)
2016-02-16 14:05 UTC, Rémi Mayrand-Provencher
Details | Diff | Splinter Review
Bug 8609 - Add an URL validation plugin for authority and biblio frameworks (8.49 KB, patch)
2016-12-15 15:35 UTC, Charles Farmer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Frédérick Capovilla 2012-08-09 17:14:38 UTC Comment hidden (obsolete)
Comment 1 Frédérick Capovilla 2012-08-09 17:15:25 UTC
Patch sponsored by the CCSR ( http://www.ccsr.qc.ca )
Comment 2 Frédérick Capovilla 2013-04-26 20:30:36 UTC
Sorry, forgot "Needs signoff".

Better late than never...
Comment 3 David Cook 2013-07-18 07:03:41 UTC
Sounds like a good idea Frédérick! 

Can you provide a test plan, so I know what to expect before and after for testing?
Comment 4 Galen Charlton 2013-08-14 17:04:57 UTC
Two thoughts:

- I think using Regexp::Common::URI to get the regular expressions would be easier to maintain.
- What about having the plugin also actively verify that the link is good?
Comment 5 I'm just a bot 2013-09-18 09:58:42 UTC
Applying: Add an URL validation plugin for authority and biblio frameworks.
Using index info to reconstruct a base tree...
M	koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt
M	koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt
M	koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt
M	koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt
CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt
CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt
CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt
Patch failed at 0001 Add an URL validation plugin for authority and biblio frameworks.
The copy of the patch that failed is found in:
   /home/christopher/git/koha/.git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Comment 6 Frédérick Capovilla 2014-03-19 18:18:56 UTC Comment hidden (obsolete)
Comment 7 simith.doliveira 2014-08-29 13:41:07 UTC Comment hidden (obsolete)
Comment 8 simith.doliveira 2014-08-29 13:49:51 UTC Comment hidden (obsolete)
Comment 9 Mark Tompsett 2015-05-08 02:23:07 UTC Comment hidden (obsolete)
Comment 10 Mark Tompsett 2015-05-08 02:23:59 UTC
"Patterns for the following URIs are supported: fax, file, FTP, gopher, HTTP, news, NTTP, pop, prospero, tel, telnet, tv and WAIS."

It does not include https. Kind of important.
Comment 11 Rémi Mayrand-Provencher 2015-07-30 12:41:18 UTC
I removed the conflicts so it can be applied properly.
I then followed the test plan and everything worked properly, including HTTPS URIs.
Comment 12 Rémi Mayrand-Provencher 2015-07-30 12:42:12 UTC Comment hidden (obsolete)
Comment 13 Marcel de Rooy 2015-07-30 12:47:54 UTC
Please check EXAMPLE.pl in the plugin directory.
You do not need plugin_parameters etc. anymore.
Comment 14 Rémi Mayrand-Provencher 2015-07-30 13:10:28 UTC Comment hidden (obsolete)
Comment 15 Héctor Eduardo Castro Avalos 2015-12-09 21:27:32 UTC
Hi Rémi

This patch doesn't apply anymore:

Conflict merge:
CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt
CONFLICT (content): Merge conflict in C4/Installer/PerlDependencies.pm

Please resolve the problem.


Please squash the two patches.
Could be great if you include changes in SQL frameworks for fresh installations and update database <http://wiki.koha-community.org/wiki/Database_updates> for frameworks already installed.

Note: For debian this package is needed libregexp-common-perl in debian/control

Regards
Comment 16 Galen Charlton 2015-12-09 22:45:38 UTC
Comment on attachment 41231 [details] [review]
Bug 8609 - Add an URL validation plugin for authority and biblio frameworks

Review of attachment 41231 [details] [review]:
-----------------------------------------------------------------

::: cataloguing/value_builder/url.pl
@@ +57,5 @@
> +    my $regex = $RE{URI};
> +    $regex =~ s/\//\\\//g;
> +
> +    my $res  = <<END_OF_JS;
> +<script typei="text/javascript">

"typei" is a typo.
Comment 17 Rémi Mayrand-Provencher 2016-02-15 20:53:53 UTC Comment hidden (obsolete)
Comment 18 Héctor Eduardo Castro Avalos 2016-02-15 21:15:26 UTC
Hi Rémi

I think IMHO QA will not approve this

cataloguing/value_builder/url.pl
>+use strict;
>+use warnings;
>+no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings
>+

This according with <https://wiki.koha-community.org/wiki/Coding_Guidelines#PERL2:_Modern::Perl>
Comment 19 Rémi Mayrand-Provencher 2016-02-16 14:05:06 UTC
Created attachment 48125 [details] [review]
Bug 8609 - Add an URL validation plugin for authority and biblio frameworks

This patch adds a new validation plugin to validate that a field/subfield contains a valid url. This plugin that can be used in biblio and authority frameworks.

Testing:

I) Before applying:

0) Go to the Cataloging module: menu->More->Cataloging;
1) Click <<New record -> default framework>> bouton;
2) Click tab << 8 >>;
3) Insert a text (for example "test") in the 856->u input field;
4) Click out of the input field;
5) Validate no message;

II) After Applying:

i) field/subfield plugin attach

0) In Koha adminstration, click << MARC bibliographic framework >>;
1) In Default framework, click << MARC structure >>;
2) Search field 856 and click << Subfields >>;
3) Click << u >>;
4) In Other options -> Plugin, choose url.pl

ii) Insert a text in the 856->u input field

0) Go to the Cataloging module: menu->More->Cataloging;
1) Click <<New record -> default framework>> bouton;
2) Click tab << 8 >>;
3) Insert a text (for example "test") in the 856->u input field;
4) Click out of the input field;
5) Validate message:
<< The field 856$u must contain a valid URL!
ex : http://www.google.com >>

Squashed all previous commits into one as asked by comment #15.
I did not see any changes made to the database so I didn't change anything related to that.

Bug8609 - Removed useless plugin_parameters sub
bug8609 fixes for comment #15 and #16
bug8609 Use Modern::Perl instead of strict and warnings
Comment 20 Marcel de Rooy 2016-02-16 17:24:43 UTC
Why not use the new style for plugins? See EXAMPLE.pl
Comment 21 Marc Véron 2016-02-16 17:29:21 UTC
In C4/Installer/PerlDependencies.pm, Regexp::Common::URI is not marked as required. Should it be marekd as required?
Comment 22 Héctor Eduardo Castro Avalos 2016-02-16 17:38:48 UTC
(In reply to Rémi Mayrand-Provencher from comment #19)

Hi Rémi and others

I applied the patch and works as expected.

You're right about my previous comment 15:

> 
> Could be great if you include changes in SQL frameworks for fresh
> installations and update database
> <http://wiki.koha-community.org/wiki/Database_updates> for frameworks
> already installed.
>

856$u in marc_subfield_structure can share this plugin and upload.pl plugin (bug 6874)

But also we can leave one of them by default, changing this:

installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.sql

> ('856', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 1, 0, 'biblioitems.url', 8, '', '', 'url.pl', 1, 0, '', '', '', NULL),

AND installer/data/mysql/atomicupdate/bug_8609_mychange.sql
>-- add url.pl to value_builder for marc_subfield_structure in 856$u
>UPDATE marc_subfield_structure SET value_builder='url.pl' WHERE tagfield='856' and tagsubfield='u';

Please give me a positive feedback


Regads
Comment 23 Charles Farmer 2016-12-15 15:35:45 UTC
Created attachment 58205 [details] [review]
Bug 8609 - Add an URL validation plugin for authority and biblio frameworks

This patch adds a new validation plugin to validate that a field/subfield contains a valid url. This plugin that can be used in biblio and authority frameworks.

Testing:

I) Before applying:

0) Go to the Cataloging module: menu->More->Cataloging;
1) Click <<New record -> default framework>> bouton;
2) Click tab << 8 >>;
3) Insert a text (for example "test") in the 856->u input field;
4) Click out of the input field;
5) Validate no message;

II) After Applying:

i) field/subfield plugin attach

0) In Koha adminstration, click << MARC bibliographic framework >>;
1) In Default framework, click << MARC structure >>;
2) Search field 856 and click << Subfields >>;
3) Click << u >>;
4) In Other options -> Plugin, choose url.pl

ii) Insert a text in the 856->u input field

0) Go to the Cataloging module: menu->More->Cataloging;
1) Click <<New record -> default framework>> bouton;
2) Click tab << 8 >>;
3) Insert a text (for example "test") in the 856->u input field;
4) Click out of the input field;
5) Validate message:
<< The field 856$u must contain a valid URL!
ex : http://www.google.com >>

----

This patch is a simple rebase to ease future developments.
Comments #20, #21 and #22 will be addressed in a another commit.
Comment 24 David Cook 2022-12-06 01:55:45 UTC
I think this functionality could be achieved just using the URI module without adding a new dependency...
Comment 25 Blou 2022-12-06 15:41:59 UTC
Our customer abandonned the rebasing of this patch five years ago.  This could be closed (if there was a close button :)
Comment 26 Katrin Fischer 2022-12-06 22:15:48 UTC
(In reply to Blou from comment #25)
> Our customer abandonned the rebasing of this patch five years ago.  This
> could be closed (if there was a close button :)

Hi Blou, you can use: RESOLVED WONTFIX in such cases.