Shoes Manual string mishandling cause an error #51

Closed
BackOrder opened this Issue Feb 1, 2015 · 4 comments

Comments

Projects
None yet
1 participant
@BackOrder
Collaborator

BackOrder commented Feb 1, 2015

Unbalanced, unescaped double quotes seem to cause the error.

TESTING SCENARIO

  • Run Shoes
  • Open The Shoes Manual
  • Open The Shoes Console (alt-/)
  • Go to the search page
  • Type oval
  • Click on arc or shape

SHOES CONSOLE

Error in <unknown> line 0 | 2015-02-01 12:22:13 -0500
(eval):1: syntax error, unexpected tIDENTIFIER, expecting ')'
...trol than ", link("strong("oval", :fill => yellow), "") { op...
...                               ^
(eval):1: syntax error, unexpected ')', expecting end-of-input
... yellow), "") { open_link("",") }, ", by offering the ", cod...
...                               ^
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:47:in `eval'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:47:in `dewikify_p'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:126:in `block (2 levels) in dewikify'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:103:in `block in wiki_tokens'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:81:in `map'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:81:in `wiki_tokens'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:111:in `block in dewikify'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:373:in `instance_eval'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:373:in `block (2 levels) in open_methods'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:367:in `each'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:367:in `block in open_methods'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:363:in `call'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:363:in `clear'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:363:in `open_methods'
C:/Program Files (x86)/Shoes/lib/shoes/help.rb:286:in `block (7 levels) in show_search'
-e:1:in `call'

image
Description for arc is missing

EXPECTED RESULT

=== arc(left, top, width, height, angle1, angle2) » Shoes::Shape ===

Draws an arc shape (a section of an oval) at coordinates (left, top). This
method just give you a bit more control than oval, by offering the
:angle1 and :angle2 styles. (In fact, you can mimick the oval method by
setting :angle1 to 0 and :angle2 to Shoes::TWO_PI.)

RELEVANT FILES
https://github.com/Shoes3/shoes3/blob/master/lib/shoes/help.rb
https://github.com/Shoes3/shoes3/blob/master/static/manual-en.txt

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Feb 2, 2015

Collaborator

The value of str at the beginnig of dewikify_p for the arc method when you navigate to _Slots > Art_:

"Draws an arc shape (a section of an oval) at coordinates (left, top). This\nmethod just give you a bit more control than [[oval]], by offering the\n:angle1 and :angle2 styles. (In fact, you can mimick the oval method by\nsetting :angle1 to 0 and :angle2 to Shoes::TWO_PI.)"

The value of str when you go to Search, type oval and click arc method:

Draws an arc shape (a section of an @oval@) at coordinates (left, top). This
method just give you a bit more control than [[@oval@]], by offering the
:angle1 and :angle2 styles. (In fact, you can mimick the @oval@ method by
setting :angle1 to 0 and :angle2 to Shoes::TWO_PI.)

Collaborator

BackOrder commented Feb 2, 2015

The value of str at the beginnig of dewikify_p for the arc method when you navigate to _Slots > Art_:

"Draws an arc shape (a section of an oval) at coordinates (left, top). This\nmethod just give you a bit more control than [[oval]], by offering the\n:angle1 and :angle2 styles. (In fact, you can mimick the oval method by\nsetting :angle1 to 0 and :angle2 to Shoes::TWO_PI.)"

The value of str when you go to Search, type oval and click arc method:

Draws an arc shape (a section of an @oval@) at coordinates (left, top). This
method just give you a bit more control than [[@oval@]], by offering the
:angle1 and :angle2 styles. (In fact, you can mimick the @oval@ method by
setting :angle1 to 0 and :angle2 to Shoes::TWO_PI.)

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Feb 2, 2015

Collaborator

Line 29 in dewikify_hi will cause a terms to be marked up for highlighting. Line 39 in dewikify_p will do the actual highlighting.

https://github.com/Shoes3/shoes3/blob/master/lib/shoes/help.rb#L29

gsub(/#{Regexp::quote(terms)}/i, '@\0@').

https://github.com/Shoes3/shoes3/blob/master/lib/shoes/help.rb#L39

gsub(/@(.+?)@/m, '", strong("\1", :fill => yellow), "').

The offending markup in manual-en.txt is [[oval]] because it becomes [[@oval@]] when highlighted. The fall through gsub will first treat @oval@ generating a strong emphasis and then treat [[]] trying to generate a link to open a section/method, resulting in a disaster.

Collaborator

BackOrder commented Feb 2, 2015

Line 29 in dewikify_hi will cause a terms to be marked up for highlighting. Line 39 in dewikify_p will do the actual highlighting.

https://github.com/Shoes3/shoes3/blob/master/lib/shoes/help.rb#L29

gsub(/#{Regexp::quote(terms)}/i, '@\0@').

https://github.com/Shoes3/shoes3/blob/master/lib/shoes/help.rb#L39

gsub(/@(.+?)@/m, '", strong("\1", :fill => yellow), "').

The offending markup in manual-en.txt is [[oval]] because it becomes [[@oval@]] when highlighted. The fall through gsub will first treat @oval@ generating a strong emphasis and then treat [[]] trying to generate a link to open a section/method, resulting in a disaster.

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Feb 2, 2015

Collaborator

SOLUTION:

Insert on line 39, https://github.com/Shoes3/shoes3/blob/master/lib/shoes/help.rb#L39

gsub(/\[\[(.+\.)?@(.+?)@\]\]/m, '", link(strong("\2".empty? ? "\1" : "\2" , :fill => yellow)) { open_link("\1\2") }, "').

Also, change [[oval]] for [[Art.oval]] in https://github.com/Shoes3/shoes3/blob/master/static/manual-en.txt#L1683.

Collaborator

BackOrder commented Feb 2, 2015

SOLUTION:

Insert on line 39, https://github.com/Shoes3/shoes3/blob/master/lib/shoes/help.rb#L39

gsub(/\[\[(.+\.)?@(.+?)@\]\]/m, '", link(strong("\2".empty? ? "\1" : "\2" , :fill => yellow)) { open_link("\1\2") }, "').

Also, change [[oval]] for [[Art.oval]] in https://github.com/Shoes3/shoes3/blob/master/static/manual-en.txt#L1683.

BackOrder added a commit that referenced this issue Feb 2, 2015

Update manual-en.txt
Partial fix for #51

BackOrder added a commit that referenced this issue Feb 2, 2015

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Feb 2, 2015

Collaborator

This issue is fixed. Should have committed with message _fixes #51_ instead of fixing #51.

Collaborator

BackOrder commented Feb 2, 2015

This issue is fixed. Should have committed with message _fixes #51_ instead of fixing #51.

@BackOrder BackOrder closed this Feb 2, 2015

@BackOrder BackOrder added this to the 3.2.21 milestone Feb 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment