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

htmlspecialchars(): Argument #1 ($string) must be of type string, array given #184

Open
3 tasks done
hktang opened this issue Jan 26, 2024 · 2 comments
Open
3 tasks done

Comments

@hktang
Copy link

hktang commented Jan 26, 2024

Hi, I run into a TypeError when rendering BibTex format. Could you point me to where I should check?

General troubleshooting steps:

  • I read the README and followed the instructions.
  • I am sure that the used CSL metadata follows the CSL schema.
  • I use a valid CSL stylesheet

Bug reports:

  1. I retrieve citeproc-JSON metadata from DOI content negotiation.
  2. I feed it into citeProc and select "bibtex" as the output format.
  3. I receive the following error message for some publications:
htmlspecialchars(): Argument #1 ($string) must be of type string, array given in htmlspecialchars() 
(line 237 of /var/www/html/vendor/seboettg/citeproc-php/src/Rendering/Text.php).

For some other (less complex?) metadata, the bibtex output renders successfully.

Used CSL stylesheet:

bibtex.csl

Used CSL metadata

Below is the metadata I used (abstract and references removed).

[{
    "indexed": {
        "date-parts": [
            [
                2023,
                11,
                9
            ]
        ],
        "date-time": "2023-11-09T00:41:10Z",
        "timestamp": 1699490470291
    },
    "reference-count": 54,
    "publisher": "MDPI AG",
    "issue": "22",
    "license": [
        {
            "start": {
                "date-parts": [
                    [
                        2023,
                        11,
                        8
                    ]
                ],
                "date-time": "2023-11-08T00:00:00Z",
                "timestamp": 1699401600000
            },
            "content-version": "vor",
            "delay-in-days": 0,
            "URL": "https:\/\/creativecommons.org\/licenses\/by\/4.0\/"
        }
    ],
    "funder": [
        {
            "name": "Institute of Global Environmental Strategies, Hayama, Japan"
        }
    ],
    "content-domain": {
        "domain": [],
        "crossmark-restriction": false
    },
    "abstract": "",
    "DOI": "10.3390\/su152215733",
    "type": "journal-article",
    "created": {
        "date-parts": [
            [
                2023,
                11,
                8
            ]
        ],
        "date-time": "2023-11-08T12:02:05Z",
        "timestamp": 1699444925000
    },
    "page": "15733",
    "source": "Crossref",
    "is-referenced-by-count": 0,
    "title": "Monitoring G20 Countries\u2019 SDG Implementation Policies and Budgets Reported in Their Voluntary National Reviews (VNRs)",
    "prefix": "10.3390",
    "volume": "15",
    "author": [
        {
            "ORCID": "http:\/\/orcid.org\/0000-0002-1651-7843",
            "authenticated-orcid": false,
            "given": "Mark",
            "family": "Elder",
            "sequence": "first",
            "affiliation": [
                {
                    "name": "Institute for Global Environmental Strategies, Hayama 240-0115, Japan"
                }
            ]
        },
        {
            "ORCID": "http:\/\/orcid.org\/0000-0003-0671-5026",
            "authenticated-orcid": false,
            "given": "Elli",
            "family": "Newman",
            "sequence": "additional",
            "affiliation": [
                {
                    "name": "Energy Innovation, San Francisco, CA 94111, USA"
                }
            ]
        }
    ],
    "member": "1968",
    "published-online": {
        "date-parts": [
            [
                2023,
                11,
                8
            ]
        ]
    },
    "container-title": "Sustainability",
    "original-title": [],
    "language": "en",
    "link": [
        {
            "URL": "https:\/\/www.mdpi.com\/2071-1050\/15\/22\/15733\/pdf",
            "content-type": "unspecified",
            "content-version": "vor",
            "intended-application": "similarity-checking"
        }
    ],
    "deposited": {
        "date-parts": [
            [
                2023,
                11,
                8
            ]
        ],
        "date-time": "2023-11-08T12:31:10Z",
        "timestamp": 1699446670000
    },
    "score": 1,
    "resource": {
        "primary": {
            "URL": "https:\/\/www.mdpi.com\/2071-1050\/15\/22\/15733"
        }
    },
    "subtitle": [],
    "short-title": [],
    "issued": {
        "date-parts": [
            [
                2023,
                11,
                8
            ]
        ]
    },
    "references-count": 54,
    "journal-issue": {
        "issue": "22",
        "published-online": {
            "date-parts": [
                [
                    2023,
                    11
                ]
            ]
        }
    },
    "alternative-id": [
        "su152215733"
    ],
    "URL": "http:\/\/dx.doi.org\/10.3390\/su152215733",
    "relation": {},
    "ISSN": [
        "2071-1050"
    ],
    "subject": [
        "Management, Monitoring, Policy and Law",
        "Renewable Energy, Sustainability and the Environment",
        "Geography, Planning and Development",
        "Building and Construction"
    ],
    "container-title-short": "Sustainability",
    "published": {
        "date-parts": [
            [
                2023,
                11,
                8
            ]
        ]
    }
}]
@hktang
Copy link
Author

hktang commented Jan 26, 2024

I did a couple of more tests by changing the following line so that it outputs serialized data:

htmlspecialchars($value, ENT_HTML5)

Then it seems at least the ISSN and Rights elements are passed in as an array. Should I check the DOI content negotiation output, or is it something we can fix by updating the bibtex.csl? I am new to CSL so any suggestion will be appreciated.

@rtournoy
Copy link

Hi, thanks for the bug report and PR, I have the same problem
Can we help? Is there any update on this?

rtournoy added a commit to rtournoy/citeproc-php that referenced this issue Aug 20, 2024
…): Argument seboettg#1 ($string) must be of type string, array given

CF issue seboettg#184 seboettg#184

Signed-off-by: Raphaël Tournoy <rtournoy@users.noreply.github.com>
rtournoy added a commit to rtournoy/citeproc-php that referenced this issue Aug 20, 2024
…): Argument seboettg#1 ($string) must be of type string, array given

CF issue seboettg#184 seboettg#184

Signed-off-by: Raphaël Tournoy <rtournoy@users.noreply.github.com>
rtournoy added a commit to rtournoy/citeproc-php that referenced this issue Aug 20, 2024
…): Argument seboettg#1 ($string) must be of type string, array given

CF issue seboettg#184 seboettg#184

Signed-off-by: Raphaël Tournoy <rtournoy@users.noreply.github.com>
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