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

Alt match cannot be used inside copyrightText #162

Open
ppisar opened this issue Apr 19, 2023 · 7 comments
Open

Alt match cannot be used inside copyrightText #162

ppisar opened this issue Apr 19, 2023 · 7 comments

Comments

@ppisar
Copy link

ppisar commented Apr 19, 2023

When adding Latex2e-translated-notice in spdx/license-list-XML#1932, I wanted a @copyright{} string in a copyrightText block to be an alternation to a Unicode © string. My motivation was to match both source in texinfo language and a rendered text.

It turned out that licenseListPublisher-2.2.8.jar was unable to handle it. It seems that the curly brackets are separated from the adjacent "copyright" word before the alternation match is performed.

Here is a minimal reproducer:

$ cat src/test.xml
<?xml version="1.0" encoding="UTF-8"?>
<SPDXLicenseCollection xmlns="http://www.spdx.org/license">
   <license isOsiApproved="false" licenseId="test"
   name="test alt match with curly brackets" listVersionAdded="0">
     <text>
       <copyrightText>
         <p>
           before <alt name="symbol" match="@copyright\{\}">@copyright{}</alt> after
           <!--before @copyright{} after-->
         </p>
       </copyrightText>
     </text>
   </license>
</SPDXLicenseCollection>

$ cat test/simpleTestForGenerator/test.txt 
before @copyright{} after

$ ./test-one-license test
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
Difference found comparing to test file: Unable to find the text ' after  ";match=".{0,5000}">>
' following a variable rule 'symbol' starting at line #1 column #20 ""

If the alternation is out of copyrightText block, it works.

Maybe related issues: #87, #100.

@goneall
Copy link
Member

goneall commented Apr 19, 2023

Thanks @ppisar for reporting this along with the details on the publisher behaviour.

I'll take a look at a solution after the OSSNA Summit (quite busy with SPDX 3.0 stuff).

@goneall
Copy link
Member

goneall commented May 10, 2023

It looks like this is an issue with the <copyrightText> tag generating an alt/var tag around the alt/var tag in the XML.

Here's the template file generated:

<<var;name="copyright";original="before <<var;name="symbol";original="@copyright{}";match="@copyright\{\}">> after  ";match=".{0,5000}">>

@ppisar - can you try omitting the <copyrightText> tag and see if it works?

@goneall
Copy link
Member

goneall commented May 10, 2023

Note: We should check for this situation in the publisher and report an appropriate error rather than generating a template which won't work.

@ppisar
Copy link
Author

ppisar commented May 11, 2023

I've already written in my original report that the alternation works outside copyrightText tree.

@goneall
Copy link
Member

goneall commented May 11, 2023

I've already written in my original report that the alternation works outside copyrightText tree.

Thanks @ppisar - I missed that in the original report.

The issue is a bit more general - Alt matches just won't work inside copyrightText. I'm going to update the title to reflect this.

This would be a very difficult issue to fix with the current design, so it may be a while before this is actually fixed. As a work around we can avoid alt tags inside copyrightText. Turns out there is already a general matching pattern generated for the copyrightText, so matches should still work.

@goneall goneall changed the title Alt match cannot handle curly brackets in copyrightText Alt match cannot be used inside copyrightText May 11, 2023
@ppisar
Copy link
Author

ppisar commented May 11, 2023

That's understandable. Then please update the documentation. If possible, also the XML schema not to accept alt inside copyrightText.

@goneall
Copy link
Member

goneall commented May 11, 2023

@ppisar I created spdx/license-list-XML#1964 to update the documentation and spdx/license-list-XML#1965 to track the request to update the schema

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

No branches or pull requests

2 participants