Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roffit: fix special characters and broken links #7

Merged
merged 7 commits into from
Jul 21, 2023

Conversation

jhauga
Copy link
Owner

@jhauga jhauga commented Jul 21, 2023

Regarding some suggested edits:

Unable to achieve fix with text2name and do_encode.
In short - new things break.

Quick takeaway ( where - (1) should be => (2) becomes ):
name="--any-option" => name=""--any-option" ("" at start)
name="ANY_NAMES" => name="ANYNAMES" (_ is removed)

For details see:

collapsed section

Detailed report (explains above):


Since curl.1 is a good use case for thoroughly testing a roffit
build I made two files, running "diff" command on them:

  1. with current badger roffit
  2. with (multiple) edited roffit

Below are sample outcomes from two instances of build, and then results
from using current edits.

do_encode --- example case removes ":

sub do_encode($) {
    return encode_entities(shift, q{<>&'#});
}

results in:
name=""--any-option" (2 "" at start)

text2name --- example case adds special characters to $text:

sub text2name { .....
   $text =~ s/[^a-zA-Z0-9-`~!@\$%^*()-_=+{};:\'\\|,.?]//g;
   ...}

results in:
name="socks5h://" (should be name="socks5h").
or
name="AUNDERSCORE" (shoud be name="A_UNDERSCORE").

Several variations of the above edits were done with similar (if not the same) outcome.

So in conclusion; either my approaches were flawed, or I need to study the roffit
file some more.

When "diff" ran using -- 2. with current pull roffit --

  • roffit built as expected, nothing new broken
  • Outputted difference resolved roffit #36.

Edits

  • Reordered htmlentity variable to be same order as call in do_encode (excluding ").

  • Edited regular expression for special character options to fix a missed bug
    that removed inline comma in option text. (i.e. "-? --opt" => "-?, --opt").

  • Removed condition in field_anchor subroutine to reduce line numbers,
    moving line needed to line number 289.

jhauga added 7 commits July 20, 2023 18:33
Removed option and added to description as to validate roffit build.

Changed description regarding empty protocols.

Fixed minor typos.
Tried to achieve per review regarding subroutines, unable to 
achieve, but left descriptive comments as to why.

Added subroutine field_anchor to run repeated commands
 - was not able to achieve with text2name
 - anchor and/or anchor links were affected when used in 
    text2name as: 
    - condition
    - part of statement

Defined $field, and $htmlentity for global use as 
now being used in subroutine field_anchor.

Added line to clean puctuations outside of "a" tag when
fixing broken links.

Changed back prior inline HTML.
For "make test" for testpage.dump to match testpage.output.
Additional edits to regular expression for special character options.

Removed condition in field_anchor subroutine, including the one line needed in "linkfile" subroutine; to reduce line numbers.

Regarding suggested edits:
Unable to achieve fix with test2name and do_encode. 
In short - new things break. 

Quick takeaway (should be => becomes):
name="--any-option" => name=""--any-option" ("" at start)
name="ANY_NAME" => name="ANYNAME" (_ removed)

Detailed report (explains above):
Since curl.1 is a good use case doing a local test with roffit I
made two files:
   1. with current badger roffit
   2. with (multiple) edited roffit
and ran "diff" command on them: 

___
One example case remove " in do_encode where:
sub do_encode($) {
    return encode_entities(shift, q{<>&'#});
}

results in:
name=""--any-option" (2 "" at start)
___

___
One example case add special characters in text2name:
sub text2name { .....
   $text =~ s/[^a-zA-Z0-9-`~!@\$%^*()-_=+{};:\'\\|,.?]//g;
   ...}

results in:
name="socks5h://" (should be socks5h).
or 
name="AUNDERSCORE" (shoud be A_UNDERSCORE).
___

When 2. with current pull roffit; no new things were broken.
Generated testpage with bug fix from roffit.
Double checked. Removed space character at end of file.
@jhauga jhauga merged commit d510204 into master Jul 21, 2023
@jhauga jhauga deleted the fix-special-characters-and-broken-links branch July 21, 2023 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Special Characters in Links and Anchor Links - curl #11381
1 participant